Skip to content

Instantly share code, notes, and snippets.

@codecaffeine
Created February 9, 2012 23:40
Show Gist options
  • Save codecaffeine/1784296 to your computer and use it in GitHub Desktop.
Save codecaffeine/1784296 to your computer and use it in GitHub Desktop.
Get a UIImage from a UIView
#import <QuartzCore/QuartzCore.h>
- (UIImage *)caf_imageRepresentation
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0.0);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment