Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save yuanhao/77de5b959a3ca834f0d5 to your computer and use it in GitHub Desktop.

Select an option

Save yuanhao/77de5b959a3ca834f0d5 to your computer and use it in GitHub Desktop.
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect rect = CGRectMake(250,61 ,410, 255);
CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], rect);
UIImage *img = [UIImage imageWithCGImage:imageRef];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
CGImageRelease(imageRef);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment