2017-08-17 104 views
-4

我如何创建一个类似于WhatsApp中的弹出式菜单?如何在iOS中创建一个弹出式菜单?

Click to view the screenshot

对不起,愚蠢的问题,但我不知道去搜一下。我很确定这不是UIPickerView

+1

,应先查看[iOS的人机接口指南](https://developer.apple.com/ios/human-interface-guidelines/)发布这样的问题之前,这个。 – rmaddy

回答

1

这是一个UIAlertControlleractionSheet首选样式。您可以初始化一个这样的:

let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) 

alert.addAction(UIAlertAction(title: "Action 1", style: .default) { _ in 
    <handler> 
}) 

alert.addAction(UIAlertAction(title: "Action 2", style: .default) { _ in 
    <handler> 
}) 

present(alert, animated: true) 

阅读documentation关于它的iOS人机界面指南。