Skip to content

Instantly share code, notes, and snippets.

@bclubb
Created February 19, 2011 19:15
Show Gist options
  • Select an option

  • Save bclubb/835289 to your computer and use it in GitHub Desktop.

Select an option

Save bclubb/835289 to your computer and use it in GitHub Desktop.
#import "UIView+Screenshot.h"
@implementation UIView (Screenshot)
-(UIImageView *)screenshot{
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *imageview = [[[UIImageView alloc] initWithImage:viewImage] autorelease];
imageview.frame = self.frame;
return imageview;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment