#swift #blur #uialertcontroller #skstorereviewcontroller
Вопрос:
Я знаю, как добавить размытый фон в 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)
}
Было успешно добавить размытый фон, но это было раннее размытие фона, прежде чем всплывет предупреждение, и я закроюсь, и это не позволит мне удалить размытие, так что есть идеи?