当我调用这个分机时,我得到了以下错误:
extension UIView {
/// Create image snapshot of view.
func snapshot(of rect: CGRect? = nil) -> UIImage {
return UIGraphicsImageRenderer(bounds: rect ?? bounds).image { _ in
drawHierarchy(in: bounds, afterScreenUpdates: true)
}
}
}错误:
vImageConvert_AnyToAny -失败宽度=0高=1 dst组件=16位浮点数dstLayout = ByteOrder16Little dstBytesPerRow =0 src组件=16位整数srcLayout = ByteOrder16Little srcBytesPerRow =0
你知道为什么会这样吗?想知道颜色空间问题..。在模拟器上工作得很好,物理设备也坏了。
发布于 2022-02-14 17:15:32
为其他需要类似服务的人找到一个解决方案:
extension UIView {
/// Create image snapshot of view.
func snapshot(of rect: CGRect? = nil) -> UIImage {
let renderer = UIGraphicsImageRenderer(bounds: rect!)
return renderer.image { (context) in
self.layer.render(in: context.cgContext)
}
}
}https://stackoverflow.com/questions/71105724
复制相似问题