STAlertController
UIAlertController的子类,可以将弹窗一个接一个地告知列表中
STAlertController是一个可以将通知一个接一个地展示在列表中的UI UIAlertController子类。当STAlertController被点击并消失后,下一个STAlertController将会展示。
需求
- iOS 8.0或更高版本
- ARC
- Swift 5.0
安装
STAlertController可以通过CocoaPods获得。要安装它,只需将以下行添加到您的Podfile中
pod 'STAlertController'
用法
在源文件中添加头文件
在需要使用库的源文件中,导入头文件
import STAlertController
初始化 STAlertController
使用以下函数初始化 STAlertController
let alertController = STAlertController(title: "Title", message: "Message", preferredStyle: .alert)
初始化 STAlertAction
使用以下函数初始化 STAlertAction
let alertAction = STAlertAction.createAction(title: "OK", style: .cancel) { action in
print("Clicked OK")
}
AddAction
使用以下函数将 STAlertAction 添加到 STAlertController
alertController.addAction(alertAction)
PresentAlertController
最后,使用以下函数在 UIViewcontroller 实例上展示 STAlertController
presentAlertController(alertController)
DismissAlertController
当然,以下方法也可以用来解散 STAlertController
dismissAlertController()
作者
Suta, [email protected]