Like this:
UIGraphicsBeginImageContext(myView.bounds.size);
[myView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *myImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
You will need to enable the CoreGraphics structure and import CALayer.h:
#import <QuartzCore/CALayer.h>
source
share