好的,抱歉,如果标题有点困惑。基本上我正在尝试获取 ImageView 的图像/ subview 并将它们组合成一个可导出的 UIImage。
这是我当前的代码,但是它有很大的分辨率损失。
func generateImage() -> UIImage{
UIGraphicsBeginImageContext(environmentImageView.frame.size)
var context : CGContextRef = UIGraphicsGetCurrentContext()
environmentImageView.layer.renderInContext(context)
var img : UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img
}
最佳答案
您必须将上下文的比例设置为视网膜。
UIGraphicsBeginImageContextWithOptions(environmentImageView.frame.size, false, 0)
0
表示使用同样适用于非 Retina 设备的屏幕比例。
关于ios - 从 UIImageView 生成图像时分辨率损失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30742200/