尝试将图像保存到相机卷SWIFT时出现问题

时间:2021-12-16 21:24:08

Encountered a strange issue while trying to save a view. The picture saved crops out the image.

在尝试保存视图时遇到一个奇怪的问题。保存的图片裁剪出图像。

here is the code :

这是代码:

    let scale = UIScreen.mainScreen().scale

    let size:CGSize = CGSize(width: CGFloat(self.customView!.frame.size.width), height:  CGFloat(self.customView!.frame.size.height))


    UIGraphicsBeginImageContextWithOptions( size, false, scale);

    self.customView!.layer.renderInContext(UIGraphicsGetCurrentContext())
    let screenshot = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()

    UIImageWriteToSavedPhotosAlbum(screenshot, nil, nil, nil)

Please help! thanks in advance

请帮忙!提前致谢

1 个解决方案

#1


The camera roll has an auto zoom since the height is a bit smaller than the screen.

由于高度略小于屏幕,因此相机胶卷具有自动变焦功能。

#1


The camera roll has an auto zoom since the height is a bit smaller than the screen.

由于高度略小于屏幕,因此相机胶卷具有自动变焦功能。