I am trying to take a screenshot of entire webView(UIWebView) and store it as a UIImage for later retrieval.
The code I have is:
var tempView = webView.scrollView.snapshotViewAfterScreenUpdates(true)
UIGraphicsBeginImageContextWithOptions(tempView.bounds.size, false, 0)
webView.drawViewHierarchyInRect(tempView.frame, afterScreenUpdates: true)
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
When I replace the first line of code with
var tempView = webView.snapshotViewAfterScreenUpdates(true)
I get the screenshot of the visible portion of the webView. But my aim is to get the entire webView screenshot including the invisible portion.
Appreciate the help in this regard.
EDIT: I have been able to get a screenshot of the scrollview using the renderInContext. But I read that the drawViewInHierarcyRect is much performant than renderinContext() and I would like to take advantage of this. I also would like to compare the memory usage of the both the methods.
For taking screenshot of visible region, renderInContext creates 4 7MB temp memory chunks, while drawViewInHierarchy creates 2 <9MB chunks of temp memory.