如何在iOS中创建弹出菜单?
问题描述:
如何创建类似于WhatsApp中出现的弹出菜单?
How can I create a popup menu like the one present in WhatsApp?
很抱歉,您的问题很愚蠢,但我什至不知道要搜索什么.我很确定它不是UIPickerView
.
Sorry for the dumb question, but I don't even know what to search. I'm pretty sure it's not a UIPickerView
.
答
这是具有actionSheet
首选样式的UIAlertController
.您可以像这样初始化一个:
This is a UIAlertController
with an actionSheet
preferred style. You can initialize one like this:
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)
阅读文档在iOS人机界面指南中.
Read the documentation about it in the iOS Human Interface Guidelines.