CleanyModal 是轻松使用 UI 定制警告的好方法
功能
- 显示一些干净的警告(与 UIAlertViewController 相同的 API)
- 轻松添加 Textfields 或自定义视图作为包含内容的 Alert 中的 UIStackView
- 操作表
- 从一个容器视图中显示完全自定义的组件作为模态窗口
- 与 iOS 13 兼容,默认实现暗/亮模式
演示
通过提供的方法显示可高度自定义和干净的警告
使用根模态系统来显示您自定义的组件,并仅使用导航/交互功能
示例
要运行示例项目,首先克隆仓库,然后从 Example 目录运行 pod install
预览
以默认样式展示干净的 Alert
let alert = MyAlertViewController(
title: "Hello world",
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed massa a magna semper semper a eget justo",
imageName: "warning_icon")
alert.addAction(title: "OK", style: .default)
alert.addAction(title: "Cancel", style: .cancel)
present(alert, animated: true, completion: nil)
轻松应用您自己的样式/主题
class MyAlertViewController: CleanyAlertViewController {
init(title: String?, message: String?, imageName: String? = nil, preferredStyle: CleanyAlertViewController.Style = .alert) {
let styleSettings = CleanyAlertConfig.getDefaultStyleSettings()
styleSettings[.tintColor] = .yellow
styleSettings[.destructiveColor] = .pink
super.init(title: title, message: message, imageName: imageName, preferredStyle: preferredStyle, styleSettings: styleSettings)
}
}
需要进一步定制您的 Alerts 吗?
扩展样式设置密钥
public extension CleanyAlertConfig.StyleKeys {
public static let shadowOffset = CleanyAlertConfig.StyleKey<CGSize>("shadowOffset")
}
然后在您自定义 Alert 的 viewDidLoad() 实现中应用这些新密钥。如果您只想将一个自定义组件(而不是 Alert)作为模态窗口显示,直接从 CleanyModalViewController 继承
查看示例项目以了解所有可定制的功能,享受吧!
需求
- iOS 9.0+
- Swift 4.2+
安装
CleanyModal 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'CleanyModal'
作者
lory huz, [email protected]
许可
CleanyModal 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。