swift 之actionSheet 使用

前端之家收集整理的这篇文章主要介绍了swift 之actionSheet 使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

四步曲:

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)

}

}

原文链接:https://www.f2er.com/swift/324143.html

猜你在找的Swift相关文章