Skip to content

Instantly share code, notes, and snippets.

@akinLiu
Created July 13, 2013 03:12
Show Gist options
  • Save akinLiu/5989250 to your computer and use it in GitHub Desktop.
Save akinLiu/5989250 to your computer and use it in GitHub Desktop.
UIView to UIImage
- (UIImage*)toImage
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 0.0);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment