Created
January 4, 2015 12:06
-
-
Save yuanhao/82cb62da5b7aa6d5bf05 to your computer and use it in GitHub Desktop.
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
| UIView* captureView = self.view; | |
| /* Capture the screen shoot at native resolution */ | |
| UIGraphicsBeginImageContextWithOptions(captureView.bounds.size, captureView.opaque, 0.0); | |
| [captureView.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
| UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext(); | |
| UIGraphicsEndImageContext(); | |
| /* Render the screen shot at custom resolution */ | |
| CGRect cropRect = CGRectMake(0 ,0 ,1435 ,1435); | |
| UIGraphicsBeginImageContextWithOptions(cropRect.size, captureView.opaque, 1.0f); | |
| [screenshot drawInRect:cropRect]; | |
| UIImage * customScreenShot = UIGraphicsGetImageFromCurrentImageContext(); | |
| UIGraphicsEndImageContext(); | |
| /* Save to the photo album */ | |
| UIImageWriteToSavedPhotosAlbum(customScreenShot , nil, nil, nil); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment