基本用法
alert
func showAlert() {
let alert = UIAlertController(title: "title",
message: "message",
preferredStyle: UIAlertControllerStyle.alert)
let defaultAction = UIAlertAction(title: "default",
style: UIAlertActionStyle.default,
handler:{ (action: UIAlertAction) -> Void in
print("UIAlertController action :",action.title ?? "default");
})
let cancelAction = UIAlertAction(title: "cancel",
style: UIAlertActionStyle.cancel,
handler:{ (action: UIAlertAction) -> Void in
print("UIAlertController action :", action.title ?? "cancel");
})
let destructiveAction = UIAlertAction(title: "destructive",
style: UIAlertActionStyle.destructive,
handler:{ (action: UIAlertAction) -> Void in
print("UIAlertController action :", action.title ?? "cancel");
})
alert.addAction(defaultAction);
alert.addAction(cancelAction);
alert.addAction(destructiveAction);
present(alert, animated: true, completion: {
print("UIAlertController present");
})
}

alert
网友评论