Skip to content

Instantly share code, notes, and snippets.

@mtsd
Created October 31, 2012 08:19
Show Gist options
  • Select an option

  • Save mtsd/3985823 to your computer and use it in GitHub Desktop.

Select an option

Save mtsd/3985823 to your computer and use it in GitHub Desktop.
capture UIView as UIImage
- (IBAction)capture:(id)sender
{
UIImage *image = [self imageByCapture:self.view];
self.imageView.image = image;
}
- (UIImage *)imageByCapture:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment