我想以编程方式从我的应用程序截取屏幕截图并且代码工作正常但我有一个具有模糊效果的 UIVisualEffectView 并且屏幕截图给了我没有模糊的图像! 我怎样才能使屏幕截图也变得模糊?
UIGraphicsBeginImageContextWithOptions(fullView.bounds.size, true, 1)
self.fullView.layer.renderInContext(UIGraphicsGetCurrentContext())
var viewImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil)
最佳答案
要在以编程方式拍摄屏幕图像时保留 UIVisualEffectView 模糊,您必须拍摄整个屏幕的图像。
这是 Apple 提供的更技术性的定义:
Many effects require support from the window that hosts the UIVisualEffectView. Attempting to take a snapshot of only the UIVisualEffectView will result in a snapshot that does not contain the effect. To take a snapshot of a view hierarchy that contains a UIVisualEffectView, you must take a snapshot of the entire UIWindow or UIScreen that contains it. - Apple Documentation
关于ios - 以编程方式截图并在 Swift 中模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27118391/