原创软文, 转载请注明出处!
ZWAlertController
感兴趣的可以到我的GitHub上Fork其它有趣的Demo
用Swift3.0, 随手写了个好玩的库, 不足之处欢迎Issues或Fork补充建议
- 本库已更新到0.0.3 版本, 支持ZWAlertController弹出文本输入框下的中英文emoji混输以及完美支持emoji字符数限制
- 使用Swift3.0重新制作的ZWAlertController, 从内到外, 简约的界面, 爽滑的动画效果, 拓展性极高, 具有特色的可编辑的客制化提示框输入环境
- 同时更具简约风格的ZWAlert
- 效果😏:
以下是简单的介绍(国际范) (づ。◕‿‿◕。)づ)
Simple Alert View written in Swift, which can be used as a UIAlertController replacement.
It supports from iOS8! It is simple and easily customizable!
Easy to use 使用
ZWAlertController can be used as a UIAlertController
. in other words, -- 也就是说, 如果出现问题, 你也可以直接把ZWAlertController 当做官方的API UIAlertController使用, 建议大家移步ZWAlertController, 进入ExampleDemo查看详细用法
// Set title, message and alert style
let alertController = ZWAlertController(title: "title", message: "message", preferredStyle: .Alert)
// Create the action.
let cancelAction = ZWAlertAction(title: "Cancel", style: .Cancel, handler: nil)
// You can add plural action.
let okAction = ZWAlertAction(title: "OK" style: .Default) { action in
NSLog("OK action occured.")
}
// Add the action.
alertController.addAction(cancelAction)
alertController.addAction(okAction)
// Show alert
presentViewController(alertController, animated: true, completion: nil)
Customize 定制化的功能展示
- add TextField (Alert style only)
- change Fonts
- change color (Overlay, View, Text, Buttons)
Add TextField 具有限制字符功能的可输入式提示框
-
Little Tips 小技巧: 你可以使用textLimit 这个属性实现限制Alert输入的字符数(以英文字符为准, 即2个英文字符占一个中文字符位)
alertController.addTextFieldWithConfigurationHandler { textField in
// text field(UITextField) setting
// ex) textField.placeholder = "Password"
// textField.secureTextEntry = true
}
alertController.textLimit = 10
Change Design 改变Alert风格(客制化接口)
Overlay color
alertController.overlayColor = UIColor(red:235/255, green:245/255, blue:255/255, alpha:0.7)
Background color
alertController.alertViewBgColor = UIColor(red:44/255, green:62/255, blue:80/255, alpha:1)
Title (font, text color)
alertController.titleFont = UIFont(name: "GillSans-Bold", size: 18.0)
alertController.titleTextColor = UIColor(red:241/255, green:196/255, blue:15/255, alpha:1)
Message (font, text color)
alertController.messageFont = UIFont(name: "GillSans-Italic", size: 15.0)
alertController.messageTextColor = UIColor.whiteColor()
Button (font, text color, background color(default/highlighted))
alertController.buttonFont[.Default] = UIFont(name: "GillSans-Bold", size: 16.0)
alertController.buttonTextColor[.Default] = UIColor(red:44/255, green:62/255, blue:80/255, alpha:1)
alertController.buttonBgColor[.Default] = UIColor(red: 46/255, green:204/255, blue:113/255, alpha:1)
alertController.buttonBgColorHighlighted[.Default] = UIColor(red:64/255, green:212/255, blue:126/255, alpha:1)
// Default style : [.Default]
// Cancel style : [.Default] → [.Cancel]
// Destructive style : [.Default] → [.Destructive]
Installation 安装:
ZWAlertController is available through CocoaPods.
To install add the following line to your Podfile:
pod 'ZWAlertController'