SwAlert
UIAlertController 的包装,用 Swift 编写。
用法
显示不带操作的警告
SwAlert.showAlert("no action title", message: "no action message", buttonTitle: "button title")
显示带有简单动作和完成处理程序的警告
SwAlert.showAlert("one action title", message: "no action message", buttonTitle: "button title") { result in
println("showOneActionAlert completion")
}
显示带有某些动作和完成处理程序的警告
SwAlert(title: "double action title", message: "double action message")
.addAction("double action 1") { result in
println("double action 1 completion")
}
.setCancelAction("cancel action") { result in
println("cancel action completion")
}
.show()
显示文本字段动作警报和CompletionHandler
SwAlert(title: "text action title", message: "text action message")
.addTextField("text action 1 title", placeholder: "text action 1 placeholder")
.addTextField("text action 2 title", placeholder: "text action 2 placeholder")
.addAction("text action") { result in
println(result) // Other(["text action 1 title", "text action 2 title"])
}
.show()
Objc版本
要求
要求
- Xcode 10.2+
操作系统 | Swift | |
---|---|---|
v1.1.x | iOS 9+ | 4.0 |
v1.2.x | iOS 10+ | 5.0 |
安装
use_frameworks!
pod "SwAlert"
许可
MIT许可。更多信息请参阅LICENSE文件。