FancyAlert
- 更华丽的警告框
- 它可以用作UIAlert
需求
- Swift 4.0, iOS 9.0
安装
- 使用Cocoapods
- swift4.0
pod 'FancyAlert', '~> 1.4.2'
# Then, run the following command:
$ pod install
- swift4.2
pod 'FancyAlert', '~> 1.5.1'
# Then, run the following command:
$ pod install
- swift5.0
pod 'FancyAlert', '~> 1.7.1'
# Then, run the following command:
$ pod install
示例
- 普通警告框
- 带有文本框的警告框
- 带有更多文本框的警告框
- 带有文本视图的警告框
- 带有进度条的警告框
- 操作表
使用方法
let firstAction = FancyAlertAction(title: "第一个", style: .normal, handler: {
print("第一个action")
})
let alertViewController = FancyAlertViewController(style: .alert, title: "大标题大标题大标题大标题大标题大标题大标题大标题大标题", message: "小标题小标题小标题小标题小标题小标题小标题小标题小标题小标题小标题小标题小标题小标题小标题", actions: [firstAction])
let cancelAction = FancyAlertAction(title: "取消", style: .cancel, handler: {
print("取消action")
})
alertViewController.addAction(cancelAction)
alertVC.addTextField { (textField) in
textField.placeholder = "请输入用户名"
textField.style = .gray
textField.maxInputLength = 10
} // add textField
alertVC.addTextView { (textView) in
textView.maxInputLength = 50
} // add textView
alertViewController.hasProgress = true // have progress
alertViewController.progress = 0.5 // progress value
present(alertViewController, animated: true, completion: nil)
- 全局属性可以通过
FancyAlertConfig
进行设置