Skip to content

Instantly share code, notes, and snippets.

@danie7k
Last active January 15, 2022 02:18
Show Gist options
  • Save danie7k/d423b0d471281ebb71d7be441f8b497c to your computer and use it in GitHub Desktop.
Save danie7k/d423b0d471281ebb71d7be441f8b497c to your computer and use it in GitHub Desktop.
iOS Objective-C screenshot
- (UIImage *)snapshot:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment