I'm trying to capture a full page screenshot in WKWebView. What happens is only what is visible in the viewport gets rendered and the rest of the image renders out gray. It has the right dimensions, just doesn't get all the data from the image capture.
I have tried several approaches and this one seems to have the most promise:
extension WKWebView {
// only captures part of the screen
func screenCapture(size: CGSize) -> UIImage {
var image: UIImage?
// sets the scrollView to the height of it's content
self.scrollView.bounds = CGRectMake(0, 0, size.width, size.height)
UIGraphicsBeginImageContextWithOptions(size, true, 1.0)
self.scrollView.drawViewHierarchyInRect(self.scrollView.bounds, afterScreenUpdates: true)
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}
}
Has anyone managed to capture a full screenshot of a WKWebView in iOS8+? If so, what was your solution? I'm experiencing the same issue in iOS9.