Created
October 31, 2012 08:19
-
-
Save mtsd/3985823 to your computer and use it in GitHub Desktop.
capture UIView as UIImage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (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