这是一个
UIAlertController
具有首选的样式
actionSheet
以下内容:
@IBAction func showActionSheet(_ sender : AnyObject) {
// Print out what button was tapped
func printActionTitle(_ action: UIAlertAction) {
print("You tapped \(action.title!)")
}
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
alertController.addAction(UIAlertAction(title: "Mute", style: .default, handler: printActionTitle))
alertController.addAction(UIAlertAction(title: "Contact Info", style: .default, handler: printActionTitle))
alertController.addAction(UIAlertAction(title: "Delete Chat", style: .destructive, handler: printActionTitle))
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: printActionTitle))
self.present(alertController, animated: true, completion: nil)
}