如何在iOS中创建弹出菜单?
我如何创建一个类似WhatsApp中的弹出菜单?
抱歉这个愚蠢的问题,但我甚至不知道该搜索什么。 我很确定它不是UIPickerView
。
这是一个带有actionSheet
首选样式的actionSheet
。 你可以像这样初始化一个:
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) alert.addAction(UIAlertAction(title: "Action 1", style: .default) { _ in }) alert.addAction(UIAlertAction(title: "Action 2", style: .default) { _ in }) present(alert, animated: true)
请阅读iOS人机界面指南中有关它的文档 。
它的UIAlertController
与preferredStyle – UIAlertControllerStyle.actionSheet
https://developer.apple.com/documentation/uikit/uialertcontroller