测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可 | MIT |
发布最后发布 | 2015年9月 |
SPM支持 SPM | ✗ |
由 Gonzalo Nunez 维护。
要运行示例项目,先克隆仓库,然后从 Example 目录运行 pod install
GNAlertConveniences 扩展 UIViewController,添加了一些方便的方法来帮助展示基本的 UIAlertView 而不需要所有的样板代码。
注意: 按钮 title 已本地化,但在传入这些方法之前,UIAlertController 的 title 和 message 必须本地化。
public func showAlertControllerWithTitle(title:String, message:String, okActionBlock:GNVoidCompletionBlock? = nil)
这将显示一个只有一个标题为“Ok”按钮的 UIAlertView。此按钮调用 okActionBlock。
public func showAlertControllerWithTitle(title:String, message:String, okActionBlock:GNVoidCompletionBlock, cancelActionBlock:GNVoidCompletionBlock? = nil)
这将显示一个有两个按钮的 UIAlertView。其中一个按钮标题为“Ok”,另一个按钮标题为“Cancel”。这在用户接受控制器作为确认或取消操作的方式时很有用。当点击“Ok”按钮时调用 okActionBlock,当点击“Cancel”按钮时调用 cancelActionBlock。
public func showAlertControllerWithTitle(title:String, message:String, actions:[UIAlertAction])
这显示了带有指定 title、message 和 actions 的 UIAlertView。这个函数最终被前两个调用,但将其作为公共函数也没有多大的损失。
GNAlertConveniences 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
use_frameworks!
pod "GNAlertConveniences"
Gonzalo Nunez,[email protected]
GNAlertConveniences 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。