Created
September 8, 2011 17:41
-
-
Save jdewind/1204051 to your computer and use it in GitHub Desktop.
Capture the entire contents of a UITableView or UIScrollView
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
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; | |
} |
Hi @aliamcami, I want to take a screenshot of the full content of tableview. I tried your code above but the rest of the content that doesn't fit on the screen if getting cut off. (In white in the bottom)
Do you know why? Tks
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
Hey @iPhoneNoobDeveloper can you try this?