Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
427 views
in Technique[技术] by (71.8m points)

ios - iOS 13 UIView屏幕截图无法正常工作。 运行良好的iOS 12(iOS 13 UIView screenshotting is not working properly. Working fine iOS 12)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...