我正在快速使用下面的代码将 UIImageView 捕获到一张图像中。它可以工作,但图像的质量与 UIImageView 上显示的图像质量不同。有没有办法在捕获此图像时配置质量?
private func getScreenshow(imageView:UIImageView) -> UIImage{
UIGraphicsBeginImageContext(self.imageView.frame.size)
let context = UIGraphicsGetCurrentContext()
imageView.layer.renderInContext(context!)
let screenShot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(screenShot, nil, nil, nil)
return screenShot
}
最佳答案
经过一番搜索,我发现了这个问题。我使用下面的代码来替换“UIGraphicsBeginImageContext”并且它有效。
UIGraphicsBeginImageContextWithOptions(self.imageView.frame.size, true, 0)
关于ios - 在 swift 中渲染 UIImageView 时质量松散,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36794024/