Swift简单的颜色选择器和SwiftMessage提示框
简单的颜色选择器为 KKColorListPicker 方法简单
先导入KKColorListViewControllerDelegate
var viewColor:KKColorListViewController!
viewColor = KKColorListViewController(schemeType:KKColorsSchemeType.crayola)
viewColor.delegate = self
func colorListController(_ controller:KKColorListViewController, didSelect color:KKColor)
{
viewColor.dismiss(animated: true, completion:nil)
alertColor = color
self.view.backgroundColor = alertColor.uiColor()
}
func colorListPickerDidComplete(_ controller:KKColorListViewController)
{
viewColor.dismiss(animated: true, completion:nil)
}
SwiftMessage 是一个很方便的弹出框
提供四种样式选择有多种属性设置,我这里显示出最常用的样式和最简单的方法,我在宏文件里面进行封装然后一句代码调用。
func showAlert(theme:Theme,message:String){
let alert = MessageView.viewFromNib(layout: .messageView)
alert.configureTheme(theme)
alert.configureDropShadow()
alert.configureContent(title: "提示", body: message)
alert.button?.isHidden = true
var cofing = SwiftMessages.defaultConfig
cofing.presentationContext = .window(windowLevel: .alert)
SwiftMessages.show(config: cofing, view: alert)
}
@IBAction func showAlert(_ sender: Any) {
MVVM.showAlert(theme: Theme.warning, message: textFile.text ?? "")
}
@IBAction func infoAlert(_ sender: Any) {
MVVM.showAlert(theme: Theme.info, message: textFile.text ?? "")
}
@IBAction func errorAlert(_ sender: Any) {
MVVM.showAlert(theme: Theme.error, message: textFile.text ?? "")
}
@IBAction func successAlert(_ sender: Any) {
MVVM.showAlert(theme: Theme.success, message: textFile.text ?? "")
}
上面两个库还是很好用的,日常开发中会经常用到,后续持续更新好用而且常用的第三方库
|
请发表评论