Reputation: 888
I am unsure as to what the menu is named, the one that has a list of options and pops up from the bottom of the screen. It looks like this:
How do I create one in swift, and what is it called?
Upvotes: 2
Views: 966
Reputation: 93151
It's an UIAlertController
with the preferred style of 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)
}
Upvotes: 4