How can I create a popup menu in iOS?

后端 未结 2 1772
小鲜肉
小鲜肉 2020-12-11 04:19

How can I create a popup menu like the one present in WhatsApp?

\"Screenshot

Sorry

相关标签:
2条回答
  • 2020-12-11 04:49

    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)
    

    Read the documentation about it in the iOS Human Interface Guidelines.

    0 讨论(0)
  • 2020-12-11 04:49

    Its UIAlertController with preferredStyle - UIAlertControllerStyle.actionSheet https://developer.apple.com/documentation/uikit/uialertcontroller

    0 讨论(0)
提交回复
热议问题