#import "QuartzCore/QuartzCore.h" after you added the framework to your project. Then do:
UIGraphicsBeginImageContext(yourView.frame.size);
[[yourView layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// The result is *screenshot
#import "QuartzCore/QuartzCore.h"
after you added the framework to your project. Then do:I have used the answer to improve it even further. Unfortunately, the original code only produced a mirrored image.
So here's the working code: