I am trying to capture a UIImage of the screen. However, there is a video (in a AVPlayerViewController). The capture works, but what is displayed in the AVPlayerViewController area is always empty - the rest of the screen is captured correctly.
Is there a way to capture what is in the AVPlayerViewController window too ?
This is how I am capturing the screen
func captureScreen() -> UIImage? {
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, false, UIScreen.main.scale)
self.view.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}