Skip to content

Instantly share code, notes, and snippets.

@Janak-Nirmal
Forked from jdewind/gist:1204051
Created August 5, 2013 06:34
Show Gist options
  • Save Janak-Nirmal/6153889 to your computer and use it in GitHub Desktop.
Save Janak-Nirmal/6153889 to your computer and use it in GitHub Desktop.
static UIImage* CreateImageFromView(UITableView *view)
{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(view.contentSize.width, view.contentSize.height), NO, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect previousFrame = view.frame;
view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.contentSize.width, view.contentSize.height);
[view.layer renderInContext:context];
view.frame = previousFrame;
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment