四步曲:
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)
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。