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) }
} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |