I tried to capture image from UIWebView using this method but the image contains only visible area of the screen. How do I capture full content of UIWebView including invisible areas, i.e. the entire web page into one single image?
-(UIImage*)captureScreen:(UIView*) viewToCapture{
UIGraphicsBeginImageContext(viewToCapture.bounds.size);
[viewToCapture.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
EDIT (from a comment by Vad)
Solution was to call
in the initialization, and
when the page did finish loading.
You are currently capturing only the visible part because you are limiting the image context to what’s visible. You should limit it to what’s available.
UIViewhas ascrollViewproperty that hascontentSize, telling you what is the size of the web view inside the scroll view. You can use that size to set your image context like this: