Skip to content

Instantly share code, notes, and snippets.

@yuanhao
Created January 4, 2015 12:06
Show Gist options
  • Select an option

  • Save yuanhao/82cb62da5b7aa6d5bf05 to your computer and use it in GitHub Desktop.

Select an option

Save yuanhao/82cb62da5b7aa6d5bf05 to your computer and use it in GitHub Desktop.
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