Created
August 6, 2014 17:39
-
-
Save cybersamx/430c33b19d49487d1d4c to your computer and use it in GitHub Desktop.
Create a UIImageView representing a visual snapshot of another UIView object.
This file contains 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
- (UIImageView *)createSnapshotFromView:(UIView *view) { | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0f); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[view.layer renderInContext:context]; | |
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return [[UIImageView alloc] initWithImage:snapshotImage]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment