是否可以截图一个包含CAEmitterLayer的视图?
每当我尝试时,视图都会很好地创建,但是所有的粒子都丢失了,下面是我的代码:
UIGraphicsBeginImageContext(drawingView.frame.size)
var context:CGContextRef = UIGraphicsGetCurrentContext()
drawingView.layer.renderInContext(context)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image我已经确认CAEmitterLayer在drawingView.layer上
发布于 2015-01-17 19:44:14
这适用于iOS,但现在我需要一种类似的OSX方法:
func offscreenScreenshot(drawingView:UIView) -> Image
{
UIGraphicsBeginImageContextWithOptions(drawingView.frame.size, true, 1.0)
let res = drawingView.drawViewHierarchyInRect(drawingView.bounds, afterScreenUpdates: false)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}https://stackoverflow.com/questions/27953961
复制相似问题