UIAlertController 提示窗口

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)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。