Skip to content

Instantly share code, notes, and snippets.

@st3fan
Created November 5, 2009 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st3fan/227243 to your computer and use it in GitHub Desktop.
Save st3fan/227243 to your computer and use it in GitHub Desktop.
#import <QuartzCore/QuartzCore.h>
- (UIImage*) captureView: (UIView*) view
{
UIImage* image = nil;
UIGraphicsBeginImageContext(view.frame.size);
{
CGContextRef context = UIGraphicsGetCurrentContext();
if (context != NULL) {
[((CALayer*) view.layer) renderInContext: context];
image = UIGraphicsGetImageFromCurrentImageContext();
}
}
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment