如何创建一个下拉菜单

时间:2018-09-02 15:50:56

标签: swift

如何使用swift创建这样的菜单? Example

1 个答案:

答案 0 :(得分:-1)

它是带有actionSheet的alertController。例如,在您的按钮操作中使用此方法。

func handleAlert()
  let alertController = UIAlertController(title: "Change Profile Photo", message: nil, preferredStyle: .actionSheet)
  //First action
  alertController.addAction(UIAlertAction(title: "Remove current photo", style: .destructive, handler: { (_) in
        // Your remove photo code here
    }))
  alertController.addAction(UIAlertAction(title: "Import From Facebook", style: .default, handler: { (_) in
        // Your import from facebook code here
    }))
  //Cancel action
  alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
  present(alertController, animated: true, completion: nil)
}