问题描述
当我绘制新图像时,uitextview 模糊。
绘制新图像后的第一个文本。看起来很模糊。
第二个文本被捕获
我试过这个 anwser 将帧更改为整数。
在绘制新图像之前它可以工作,但是在绘制图像时它不起作用。
这是我的代码
// UIView -> UIImage
convenience init(view: UIView) {
UIGraphicsBeginImageContextWithOptions(view.bounds.size,view.isOpaque,0)
view.drawHierarchy(in: view.bounds,afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
self.init(cgImage: image.cgImage!)
}
解决方法
将 textview 的优先级设置为比通常值更高的值。
,我通常为 UIGraphicsBeginImageContextWithOptions 指定比例值
UIGraphicsBeginImageContextWithOptions(bounds.size,false,UIScreen.main.scale)
但是 0 也应该有效。在 Apple 文档中,使用 0.0 作为比例值来使用设备比例值(就像我手动设置的那样) - 也许在当前位置 0 与 0.0 不一样的零? :)