@IBAction func showAlert(sender: AnyObject) { let alertController = UIAlertController(title: "Default Style", message: "A standard alert.", preferredStyle: .Alert) let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in } alertController.addAction(cancelAction) let destroyAction = UIAlertAction(title: "Destroy", style: .Destructive) { (action) in println(action) } alertController.addAction(destroyAction) let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in } alertController.addAction(OKAction) self.presentViewController(alertController, animated: true) { } }
原文地址:http://blog.csdn.net/rainlesvio/article/details/39889509