iOS OC&Swift炫酷的可編輯彈窗(AlertController/Alert)

原創(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'

Star me

  • 最后歡迎在GitHubStar, 被我的中英文介紹感動(dòng)到的童鞋不妨在GitHub上Fllow我, 也不妨點(diǎn)一下左下角的愛(ài)心????
  • 你可能會(huì)發(fā)現(xiàn)我另一個(gè)超好用的客制化彈幕庫(kù): ZWBarrage, 具有可點(diǎn)擊功能, 可即點(diǎn)即停, 快速上手, 不妨Star
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容