美文网首页
UIAlertController 提示窗口

UIAlertController 提示窗口

作者: 彧哥哥 | 来源:发表于2021-09-06 22:20 被阅读0次

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)

相关文章

网友评论

      本文标题:UIAlertController 提示窗口

      本文链接:https://www.haomeiwen.com/subject/newywltx.html