Hi All,
I am from a data science background and a newbie to swift programming. I would like to take the screenshot of the Webview containing a video. As of now I am able to take the screenshot of the WebView without the video. apparently the video part is shown in the black colour.
Below is the code snippet to take the screenshot
func getScreenshot() -> UIImage? {
//creates new image context with same size as view
// UIGraphicsBeginImageContextWithOptions (scale=0.0) for high res capture
UIGraphicsBeginImageContextWithOptions(view.frame.size, true, 0.0)
// renders the view's layer into the current graphics context
if let context = UIGraphicsGetCurrentContext() { view.layer.render(in: context) }
// creates UIImage from what was drawn into graphics context
let screenshot: UIImage? = UIGraphicsGetImageFromCurrentImageContext()
// clean up newly created context and return screenshot
UIGraphicsEndImageContext()
return screenshot
}
Simulator:
screenshot of the simulator:
My aim is to take the screenshot of the view and feed it to the Core ML models to get the predictions.
is it possible to take the screenshots of the Web view? If yes, could you please give me some inputs to implement it in the app?
Best, Veeresh