Reputation: 13
UIImage* image = nil;
UIGraphicsBeginImageContextWithOptions(scrollView.contentSize, YES, 0);
{
CGPoint savedContentOffset = scrollView.contentOffset;
CGRect savedFrame = scrollView.frame;
scrollView.contentOffset = CGPointZero;
scrollView.frame= CGRectMake(0, 0, scrollView.contentSize.width,scrollView.contentSize.height);
[scrollView.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
scrollView.contentOffset = savedContentOffset;
scrollView.frame = savedFrame;
}
UIGraphicsEndImageContext();
I can not get the full image form scrollview , But only a half , and the half is black
Upvotes: 1
Views: 123
Reputation: 16446
EDIT
Try to add
drawHierarchy(in: self.bounds, afterScreenUpdates: true)
after the line
[scrollView.layer renderInContext: UIGraphicsGetCurrentContext()];
Upvotes: 1