I searched a lot of time, I found some clues, but I cannot figure out how to apply this to my problem. Would thank for any help.
What is trying to achieve is quite straightforward:
My app includes WKWebview, which plays YouTube videos (with some text overlay). I added a link to take a screenshot and save it in a camera roll.
Result:
It works fine in the simulator, but on the device I can only see the result, which overlays the text and the background (it is assumed that this video) is black.
Here is my current code (SWIFT 3):
...
UIImageWriteToSavedPhotosAlbum(captureScreen(), nil, nil, nil)
...
func captureScreen() -> UIImage {
UIGraphicsBeginImageContextWithOptions(webView!.bounds.size, webView!.isOpaque, 0)
webView!.drawHierarchy(in: webView!.bounds, afterScreenUpdates: false)
let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
}
I also tried (same result)
...
UIImageWriteToSavedPhotosAlbum(captureScreen(), nil, nil, nil)
...
func captureScreen() -> UIImage {
let image = UIApplication.shared.screenShot!
return image
}
, renderInContext: GL, , . UIImageView EAGLview (link1, 2).
, objective-c (link3, link4, link5).
SWIFT.
.