2017-08-17 105 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人機界面指南。