-
-
Save Janak-Nirmal/2642693 to your computer and use it in GitHub Desktop.
Capture the entire contents of a UITableView or UIScrollView
This file contains 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment