博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
swift之UIAlertController
阅读量:4288 次
发布时间:2019-05-27

本文共 1643 字,大约阅读时间需要 5 分钟。

/** UIAlertController UIAlertController.presentAlertController(vc: self,title: "警告",sureStr: "确定",cancelStr: "取消",thirdStr: "fafda") //通过block回调来执行相应的动作 LYBAlertControllerExtention.infoMarqueeClickBlock={ (index)in print("\(index)") return } */import UIKitclass LYBAlertControllerExtention: UIAlertController {    //定义一个闭包,有参数没返回值  static  var  infoMarqueeClickBlock:(Int)->()={ (Int)in return }    }extension UIAlertController{     class  func presentAlertController(vc:UIViewController, title:String,sureStr:String,cancelStr:String,thirdStr:String){        let alertControl=UIAlertController.init(title: title, message: "", preferredStyle: UIAlertController.Style.alert)        let sure=UIAlertAction.init(title: sureStr, style: UIAlertAction.Style.default) { (ac) in            //确认操作            print("确定")            LYBAlertControllerExtention.infoMarqueeClickBlock(0)        }         alertControl.addAction(sure)              if thirdStr != ""{        let third=UIAlertAction.init(title: thirdStr, style: UIAlertAction.Style.default) { (ac) in            //取消操作---注意所有按钮中只能有一个UIAlertActionStyle.cancel类型的按钮            print("第三个")              LYBAlertControllerExtention.infoMarqueeClickBlock(1)        }        alertControl.addAction(third)        }        let cancel=UIAlertAction.init(title: cancelStr, style: UIAlertAction.Style.cancel) { (ac) in            //取消操作---注意所有按钮中只能有一个UIAlertActionStyle.cancel类型的按钮            print("取消")              LYBAlertControllerExtention.infoMarqueeClickBlock(2)        }                alertControl.addAction(cancel)                vc.present(alertControl, animated: true) {        }    }    }

 

转载地址:http://psmgi.baihongyu.com/

你可能感兴趣的文章
Android 热修复,插件式开发---基本知识
查看>>
JSP九大内置对象、四种作用域、跳转方式
查看>>
JSP 自定义标签
查看>>
JSP JavaBean
查看>>
从两个字符串中找出最大公共子字符串
查看>>
Java代码添加背景音乐
查看>>
Java面试题全集(上)
查看>>
JAVA泛型中的有界类型(extends super)
查看>>
炫酷进度条:Android 仿应用宝下载进度条
查看>>
Java程序内存的简单分析
查看>>
Javascript单例模式概念与实例
查看>>
SQL NULL 函数
查看>>
多例设计模式
查看>>
WebView的JavaScript与本地代码三种交互方式
查看>>
WebView的JavaScript与本地代码三种交互方式
查看>>
Android Studio里面配置Tesseract
查看>>
深入浅出JavaScript之this
查看>>
Android include标签的使用注意事项
查看>>
final成员变量和final局部变量
查看>>
Android数据加密之异或加密算法
查看>>