我知道如何在 UIAlertController 中添加模糊背景,但不幸的是我无法找到添加背景的方法。
使用 UIAlertController 添加模糊背景的基本编码;
// Blur
let blurEffect = UIBlurEffect(style: .light)
let blurVisualEffectView = UIVisualEffectView(effect: blurEffect)
blurVisualEffectView.frame = view.bounds
// UIAlertController
let alertController = UIAlertController.init(title: "Title", message: "Message", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action: UIAlertAction!) in
print("Handle Ok logic here")
blurVisualEffectView.removeFromSuperview()
}))
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action: UIAlertAction!) in
print("Handle Cancel Logic here")
blurVisualEffectView.removeFromSuperview()
}))
self.view.addSubview(blurVisualEffectView)
self.present(alertController, animated: true, completion: nil)
但是,这里是 SKStoreReviewController
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
// Blur
let blurEffect = UIBlurEffect(style: .light)
let blurVisualEffectView = UIVisualEffectView(effect: blurEffect)
blurVisualEffectView.frame = view.bounds
SKStoreReviewController.requestReview(in: scene)
self.view.addSubview(blurVisualEffectView)
}
添加模糊背景是成功的,但它是警报弹出之前的早期流行模糊背景,我关闭它不会让我删除模糊所以知道吗?