I found this question and the answer is perfect. But what if I want so set the size myself? How do I change the scrollView.contentOffset
for this?
For Example I want to call it like this:
#define multiplier 3.0f
CGSize size = CGSizeMake(scrollView.frame.size.width*multiplier, scrollView.frame.size.height*multiplier);
UIImage *backgroungImage = [self renderScrollViewToImageWith:scrollView size:size];
-(UIImage *)renderScrollViewToImageWith:(UIScrollView *)_scrollView size:(CGSize)size
{
UIScrollView *contentScrollView = _scrollView;
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
//what do I do here???
CGPoint offset = contentScrollView.contentOffset;
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), -offset.x, -offset.y); <-- what do I do here?
[contentScrollView drawViewHierarchyInRect:CGRectMake(0, 0, size.width, size.height) afterScreenUpdates:YES];
UIImage *visibleScrollViewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return visibleScrollViewImage;
}