I've a problem screenshotting a main UIView containing a subview showing a video stream inside it.
(我在截图主UIView时遇到了问题,该主UIView包含一个子视图,其中显示了视频流。)
When I take a screenshot the image is correct less the rectangle with the video stream that is black, stream image is not showed ! (当我截屏时,图像是正确的,减去带有黑色视频流的矩形,则不显示流图像!)
The screenshot bugged bad screenshot image
(屏幕截图错误的截图图像)
and the correct image correct screenshot image
(和正确的图像正确的截图图像)
The iOS versione is 13.2.3 and the same code works properly on iOS 12. I tried using UIGraphicsImageRenderer and renderer.image
(iOS版本是13.2.3,相同的代码在iOS 12上也可以正常工作。我尝试使用UIGraphicsImageRenderer和renderer.image)
guard let layer = UIApplication.shared.keyWindow?.layer else { return }
let renderer = UIGraphicsImageRenderer(size: layer.frame.size)
let image = renderer.image(actions: { context in
layer.render(in: context.cgContext)
})
also tried with drawHierarchy
(也尝试过drawHierarchy)
let renderer = UIGraphicsImageRenderer(size: view.bounds.size)
let image = renderer.image { context in
view.drawHierarchy(in: view.bounds, afterScreenUpdates: true)
}
and other ways always with the same bad result.
(和其他方式总是会带来同样糟糕的结果。)
It seems similar to iOS 13 UITextView converting UITextView to image is not working properly.
(似乎类似于iOS 13 UITextView将UITextView转换为图像无法正常工作。)
Working fine in below iOS 12 (在iOS 12以下的版本中工作正常)
Any idea ?
(任何的想法 ?)
ask by aldopa translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…