我在许多应用程序[Twitter,在这种情况下]看到以下[popup/overlay]菜单,我想知道它是否是标准的Swift组件/库等等,如果有的话,如果有人知道我可能会在哪里请找,谢谢?JBM
作为Larme评论它是一个UIAlertController与ActionSheet风格.
考虑以下代码:
@IBAction func showActionSheet(sender: AnyObject) {
// 1
let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: .ActionSheet)
// 2
let deleteAction = UIAlertAction(title: "Delete", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
print("File Deleted")
})
let saveAction = UIAlertAction(title: "Save", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
print("File Saved")
})
//
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
(alert: UIAlertAction!) -> Void in
print("Cancelled")
})
// 4
optionMenu.addAction(deleteAction)
optionMenu.addAction(saveAction)
optionMenu.addAction(cancelAction)
// 5
self.presentViewController(optionMenu, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
你的结果将是:
您可以根据需要进行修改.
有关更多信息,请参阅本教程.
| 归档时间: |
|
| 查看次数: |
871 次 |
| 最近记录: |