gpt4 book ai didi

ios - 警报的屏幕截图,iOS,Swift

转载 作者:搜寻专家 更新时间:2023-11-01 06:15:00 24 4
gpt4 key购买 nike

我在显示警报时截取屏幕截图,这适用于截取屏幕截图,但当它保存到相机胶卷时,它只捕获了警报后面的屏幕,并没有在屏幕截图中包含警报。

这有可能吗?

下面是我的代码。

func ScreenShot() {
//Create the UIImage
UIGraphicsBeginImageContextWithOptions(view.frame.size, true, 0)
guard let context = UIGraphicsGetCurrentContext() else { return }
view.layer.render(in: context)
guard let image = UIGraphicsGetImageFromCurrentImageContext() else { return }
UIGraphicsEndImageContext()

//Save it to the camera roll
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
}

在这里计算。

func alertShow() {

let alert = UIAlertController(title: "ALERT!!!", message: "Message stuff", preferredStyle: UIAlertControllerStyle.alert)


alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { action in

self.performSegue(withIdentifier: "toMainInfoVC", sender: nil)

}))

self.present(alert, animated: true, completion: nil)
ScreenShot()
}

最佳答案

我认为你需要关键窗口的完整层

let layer = UIApplication.shared.keyWindow!.layer
let scale = UIScreen.main.scale
UIGraphicsBeginImageContextWithOptions(layer.frame.size, false, scale);

layer.render(in: UIGraphicsGetCurrentContext()!)

关于ios - 警报的屏幕截图,iOS,Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47205042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com