ARAlertViewController
要求
- iOS 9.0
- Xcode 11.0+
- Swift 5+
安装
ARAlertViewController 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中
pod 'ARAlertViewController'
然后,运行以下命令
pod install
使用
导入
import ARAlertViewController
初始化
然后在你的viewController中调用如下
以显示默认警告 无完成块
self.showAlert(title: "Alert", message: "Add a message you want to show", btnTitle: "OK", alertType: .defaultAlert)
带有完成块
self.showAlert(title: "Alert", message: "Add a message you want to show", btnTitle: "OK", alertType: .defaultAlert) {
print("User clicked on ok button")
}
以显示自定义警告 无完成块
self.showAlert(title: "Alert", message: "Add a message you want to show", btnTitle: "OK", alertType: .customAlert)
带有完成块
self.showAlert(title: "Alert", message: "Add a message you want to show", btnTitle: "OK", alertType: .customAlert) {
print("User clicked on ok button")
}
还有其他辅助函数可用于显示用于 错误
和 成功
的警告
以显示 错误
self.showErrorAlertWithMessage(message: "add error message here", alertType: .customAlert) {
print("User clicked on Default Error ok button")
}
和显示 成功
self.showSuccessAlertWithMessage(message: "Add you Success message there", alertType: .customAlert) {
print("User clicked on success ok button")
}
作者
AshrafRehmanWarraich, [email protected]
许可
ARAlertViewController 是在 MIT 许可下发布的。有关详细信息,请参阅 LICENSE。