代码之家  ›  专栏  ›  技术社区  ›  Ethan SK

如何使WhatsApp风格的更多按钮菜单iOS Swift

  •  0
  • Ethan SK  · 技术社区  · 8 年前

    我不确定菜单的名字,它有一个选项列表,从屏幕底部弹出。看起来是这样的: enter image description here

    我如何在swift中创建一个,它叫什么?

    1 回复  |  直到 8 年前
        1
  •  3
  •   Code Different    8 年前

    这是一个 UIAlertController 具有首选的样式 actionSheet 以下内容:

    @IBAction func showActionSheet(_ sender : AnyObject) {
        // Print out what button was tapped
        func printActionTitle(_ action: UIAlertAction) {
            print("You tapped \(action.title!)")
        }
    
        let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
        alertController.addAction(UIAlertAction(title: "Mute", style: .default, handler: printActionTitle))
        alertController.addAction(UIAlertAction(title: "Contact Info", style: .default, handler: printActionTitle))
        alertController.addAction(UIAlertAction(title: "Delete Chat", style: .destructive, handler: printActionTitle))
        alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: printActionTitle))
        self.present(alertController, animated: true, completion: nil)
    }