加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift 之actionSheet 使用

发布时间:2020-12-14 07:06:40 所属栏目:百科 来源:网络整理
导读:四步曲: 1、创建 UIAlertController 警告控制器 2、创建 UIAlertAction 警告行为 3、将 UIAlertAction 添加到 UIAlertController 4、 present出 UIAlertController 警告控制器 直接上代码 import UIKit class ViewController: UIViewController { var contr

四步曲:

1、创建UIAlertController 警告控制器

2、创建UIAlertAction 警告行为

3、将UIAlertAction 添加到UIAlertController

4、present出UIAlertController 警告控制器


直接上代码


import UIKit


class ViewController: UIViewController {

var controller:UIAlertController?

override func viewDidLoad() {

super.viewDidLoad()

controller = UIAlertController(

title: "Choose how you would like to share this photo",

message: "You cannot bring back a deleted photo",

preferredStyle: .ActionSheet)

let actionEmail = UIAlertAction(title: "Via email",

style: UIAlertActionStyle.Default,

handler: {(paramAction:UIAlertAction!) in

/* Send the photo via email */

})

let actionImessage = UIAlertAction(title: "Via iMessage",0)"> /* Send the photo via iMessage */

})

let actionDelete = UIAlertAction(title: "Delete photo",175)"> style: UIAlertActionStyle.Destructive,0)"> /* Delete the photo here */

})

controller!.addAction(actionEmail)

controller!.addAction(actionImessage)

controller!.addAction(actionDelete)

}

override func viewDidAppear(animated: Bool) {

super.viewDidAppear(animated)

self.presentViewController(controller!,animated: true,completion: nil)

}

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读