Skip to content

Instantly share code, notes, and snippets.

@jdewind
Created September 8, 2011 17:41
Show Gist options
  • Save jdewind/1204051 to your computer and use it in GitHub Desktop.
Save jdewind/1204051 to your computer and use it in GitHub Desktop.
Capture the entire contents of a UITableView or UIScrollView
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;
}
@kent2508
Copy link

kent2508 commented May 13, 2020

All content which is not rendered at bottom of table can not be captured. You just captured what was rendered in the screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment