swift 4 / Xcode 11
Привет.Чтобы отключить взаимодействие с пользователем (пример: нажатие в любом месте, кроме кнопки отмены), вызовите текущий метод в своей функции оповещения и установите его завершение завершения, как показано ниже.
present(alertController, animated: true) {
alertController.view.superview?.subviews[0].isUserInteractionEnabled = false
}
Весь пример:
func alertMe() {
let alertController = UIAlertController(title: "Tapping Test", message: "User Interaction on the view is disabled", preferredStyle: .actionSheet)
let cancelAction = UIAlertAction(title: "cancel", style: UIAlertActionStyle.cancel) { UIAlertAction in
// do something/call someone/or nothing :)
NSLog("cancel Button is Pressed")
}
alertController.addAction(cancelAction)
present(alertController, animated: true){
alertController.view.superview?.subviews[0].isUserInteractionEnabled = false
}
}