好的,对不起,如果标题有点令人困惑。基本上我正在尝试获取图像视图的图像/子视图,并将它们组合成一个可导出的UIImage。
这是我当前的代码,但它的分辨率损失很大。
func generateImage() -> UIImage{
UIGraphicsBeginImageContext(environmentImageView.frame.size)
var context : CGContextRef = UIGraphicsGetCurrentContext()
environmentImageView.layer.renderInContext(context)
var img : UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img
}
答案 0 :(得分:1)
您必须将上下文的比例设置为视网膜。
UIGraphicsBeginImageContextWithOptions(environmentImageView.frame.size, false, 0)
0
意味着使用适用于非视网膜设备的屏幕比例。