IOS Swift 弹出框的写法(就是Android的AlertDialog)

ios8以后是用UIAlertController来代替UIAlertView(在屏幕中间弹出)和UIActionSheet(显示在屏幕底部的弹出框)

        //定义一个UIActionSheet
        let ActionSheet = UIAlertController(title: "标题", message: "信息", preferredStyle: .ActionSheet)
        //定义一个UIAlertView的用法跟UIActionSheet是一样的只是修改一下preferredStyle就可以了
        let alert = UIAlertController(title: "标题", message: "信息", preferredStyle: .Alert)
        //添加按钮点击
        let cancelAction = UIAlertAction(title: "取消", style: .Cancel, handler: nil)
        let chooseAction = UIAlertAction(title: "确定", style: .Default, handler: nil)
        //将Action添加到弹出框中
        ActionSheet.addAction(cancelAction)
        ActionSheet.addAction(chooseAction)
        //显示弹出框
        self.presentViewController(ActionSheet, animated: true, completion: nil)

具体使用得根据自己的项目开发需要进行定义,希望这篇博客你能看得懂那是我的荣幸.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值