i want to render the offscreen content of my scrollview to an image as well.
But the following code only renders the content on screen, even though it's supposed to render the whole scrollView content.
Can anyone provide help?
Thanks in advance!
UIImage *image = nil;
UIGraphicsBeginImageContextWithOptions(scrollView.contentSize, false, 0.0);
{
CGPoint savedContentOffset = scrollView.contentOffset;
CGRect savedFrame = scrollView.frame;
scrollView.contentOffset = CGPointMake(0.0, 0.0);
scrollView.frame = CGRectMake(0, 0.0, scrollView.contentSize.width, scrollView.contentSize.height);
NSLog(@"%.2f",scrollView.contentSize.height);
[scrollView.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
scrollView.contentOffset = savedContentOffset;
scrollView.frame = savedFrame;
}
UIGraphicsEndImageContext();