LFAlertController 0.0.2

LFAlertController 0.0.2

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期最后发布日期2017年3月
SwiftSwift 版本3.0
SPM支持 SPM

Lucas Farah 维护。



  • 作者:
  • lucasfarah

LFAlertController

带有初始化处理程序的 UIAlertController Swift 扩展🔶

为什么?因为 UIAlertController 在每个操作中都有处理程序,迫使开发者要有 重复代码。相反,我们可以在任何操作被调用时,在全局处理程序内有一个 switch,该处理程序会调用

如何安装

使用 Swift 文件

LFAlertController.swift/Sources 拖动到您的项目中

使用 SPM

  .Package(url: "https://github.com/awesome-labs/LFAlertController.git", majorVersion: 0)

如何使用

初始化 UIAlertViewActions

let action1 = UIAlertAction(title: "Second Action", style: .Default)

初始化 UIAlertController

带有处理程序的 UIAlertController

self.controller = UIAlertController(title: "hey", message: "ho", preferredStyle: .Alert,actions:[action0,action1])
{ (action,index) -> () in

  //Printing index of Action
  print("\(index) - \(action.title!)")
}
显示 UIAlertController
self.controller.show()

其他选项

带有处理程序的 UIAlertAction

let action0 = UIAlertAction(title: "First Action", style: .Default, handler: nil)

不带处理程序的 UIAlertController

self.controller = UIAlertController(title: "hey", message: "ho", preferredStyle: .Alert, actions: [action0,action1])