参考:https://www.cnblogs.com/zhangguoliang1992/p/4918684.html
@IBAction func popupAlertView(_ sender: Any) {
var alertController : UIAlertController = UIAlertController(title: "显示的标题", message: "标题的提示信息", preferredStyle: UIAlertController.Style.alert)
alertController.addAction(UIAlertAction(title: "确定", style: UIAlertAction.Style.default, handler: {
_ in
NSLog("点击确认")
}))
alertController.addAction(UIAlertAction(title: "取消", style: UIAlertAction.Style.cancel, handler: {
_ in
NSLog("点击取消")
}))
alertController.addAction(UIAlertAction(title: "警告", style: UIAlertAction.Style.destructive, handler: {
_ in
NSLog("点击警告")
}))
alertController.addTextField(configurationHandler: { (textField) in
NSLog("添加一个textField就会调用 这个block");
})
self.present(alertController, animated: true, completion: nil)
}