How can I create a popup menu in iOS?

后端 未结 2 1774
小鲜肉
小鲜肉 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
       
    })
    
    alert.addAction(UIAlertAction(title: "Action 2", style: .default) { _ in
        
    })
    
    present(alert, animated: true)
    

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

提交回复
热议问题