Last active
April 5, 2017 15:43
-
-
Save manolosavi/815d91a8a6ee6184410de65c51710c7a to your computer and use it in GitHub Desktop.
Obj-C function to get a UIImage from a UIView.
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
@import QuartzCore; | |
+ (UIImage *)imageFromView:(UIView *)view { | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, 0); | |
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:true]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment