iOS8.0以上,苹果建议使用UIAlertController
提示窗口
let alertView = UIAlertController.init(title: "提示", message: "信息", preferredStyle: .alert)
let alert = UIAlertAction.init(title: "确定", style: .destructive) { (UIAlertAction) in
print("确定按钮点击")
}
let cancleAlert = UIAlertAction.init(title: "取消", style: .cancel) { (UIAlertAction) in
print("点击取消按钮")
}
alertView.addAction(cancleAlert)
alertView.addAction(alert);
self.present(alertView, animated: true, completion: nil)
底部弹出
let alertController = UIAlertController(title: "删除分类", message: "删除分类将不可恢复",preferredStyle: .actionSheet)
let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil)
let deleteAction = UIAlertAction(title: "删除", style: .destructive)
{
action in
print("大大啊的")
}
alertController.addAction(cancelAction)
alertController.addAction(deleteAction)
self.present(alertController, animated: true, completion: nil)