Is there an alternative to the CALayer -renderInContext: method?

I need a way to capture a view or screen with everything, just like the screen. -renderInContext: won't do this. Are there any alternatives to this?

+2


a source to share


1 answer


Several, but start with:

UIGetScreenImage();

      

Returns CGImageRef. If you are using this, note that the image is saved and you must release it.



Edit

For completeness, add a basic other way to do it:

UIWindow *aWindow = [[UIApplication sharedApplication].windows objectAtIndex:0];
UIGraphicsBeginImageContext(aWindow.frame.size);
[[aWindow layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

      

+1


a source







All Articles