Is it possible to take a screenshot of a view that includes a CAEmitterLayer?
Whenever I try, the view is created fine, but all of the particles are missing, here's my code:
UIGraphicsBeginImageContext(drawingView.frame.size)
var context:CGContextRef = UIGraphicsGetCurrentContext()
drawingView.layer.renderInContext(context)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
I have confirmed that the CAEmitterLayer is on the drawingView.layer
This works for iOS, but now I need a similar method for 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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With