extension UIViewController {
func showAlertWithCancel(title: String, message: String, okAction: String, cancel: String, completion: ((Bool, String) -> Void)? = nil ) {
let sb_main = UIStoryboard.init(name: "Main", bundle: nil)
let vc: CustomNewAlertVC = sb_main.instanceVC()
vc.modalPresentationStyle = .custom
vc.modalTransitionStyle = .crossDissolve
vc._ok = okAction
vc._msg = message
vc._title = title
vc._cancel = cancel
vc.delegate = { aa in
completion?(aa)
}
DispatchQueue.main.async {
self.present(vc, animated: true, completion: nil)
}
}
}
要显示警报使用: self.showAlertWithCancel(title: "Test" ....