原創(chuàng)軟文, 轉(zhuǎn)載請(qǐng)注明出處!
ZWAlertController
感興趣的可以到我的GitHub上Fork其它有趣的Demo
用Swift3.0, 隨手寫了個(gè)好玩的庫(kù), 不足之處歡迎Issues或Fork補(bǔ)充建議
- 本庫(kù)已更新到0.0.3 版本, 支持ZWAlertController彈出文本輸入框下的中英文emoji混輸以及完美支持emoji字符數(shù)限制
- 使用Swift3.0重新制作的ZWAlertController, 從內(nèi)到外, 簡(jiǎn)約的界面, 爽滑的動(dòng)畫效果, 拓展性極高, 具有特色的可編輯的客制化提示框輸入環(huán)境
- 同時(shí)更具簡(jiǎn)約風(fēng)格的ZWAlert
- 效果??:

AlertStyle.gif

SheetStyle.gif

ZWAlert.gif
以下是簡(jiǎn)單的介紹(國(guó)際范) (づ??????)づ)
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, -- 也就是說(shuō), 如果出現(xiàn)問(wèn)題, 你也可以直接把ZWAlertController 當(dāng)做官方的API UIAlertController使用, 建議大家移步ZWAlertController, 進(jìn)入ExampleDemo查看詳細(xì)用法
// 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)

Custom.gif
Add TextField 具有限制字符功能的可輸入式提示框
-
Little Tips 小技巧: 你可以使用textLimit 這個(gè)屬性實(shí)現(xiàn)限制Alert輸入的字符數(shù)(以英文字符為準(zhǔn), 即2個(gè)英文字符占一個(gè)中文字符位)
Limit-Entry-Range.gif
alertController.addTextFieldWithConfigurationHandler { textField in
// text field(UITextField) setting
// ex) textField.placeholder = "Password"
// textField.secureTextEntry = true
}
alertController.textLimit = 10
Change Design 改變Alert風(fēng)格(客制化接口)
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'
