I've a CustomView. The CustomerVIew contains 2 views, one more custom view which has WkWebview & one normal xib for branding.
This Customview is added to anotherview, screenshotview like shown below.
anothercustomtView contains the WKWebView
ContentView
let contentView = UIView(frame: screenshotBounds)
contentView.backgroundColor = UIColor.white
contentView.addSubview(anothercustomtView)
contentView.addSubview(xibbrandingView)
ScreenshotView
let screenshotView = UIView(frame: screenshotBounds.insetBy(dx: -padding, dy: -padding))
screenshotView.addSubview(contentView)
I am trying to capture the complete screen using
UIGraphicsBeginImageContextWithOptions(screenshotView.bounds.size, true, 0)
screenshotView.drawHierarchy(in: screenshotView.bounds, afterScreenUpdates: true)
let screenshot = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
however except the WKWebView which I can see on screen rest everything is captured.
If I use self.view as below, I see even the wkwebview is captured.
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, true, 0)
self.view.drawHierarchy(in: self.view.bounds, afterScreenUpdates: true)
let screenshot = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
Kind of stuck with this. Can anyone help with this? Thanks!