Skip to content

Instantly share code, notes, and snippets.

@manolosavi
manolosavi / UIImageFromUIView.m
Last active April 5, 2017 15:43
Obj-C function to get a UIImage from a UIView.
@import QuartzCore;
+ (UIImage *)imageFromView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:true];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}