SCLAlertView-Swift

简介:

SCLAlertView-Swift

https://github.com/vikmeup/SCLAlertView-Swift

 

 

Animated Alert View written in Swift, which can be used as a UIAlertView or UIAlertController replacement. Since UIAlertView is deprecated and UIAlertController only works on iOS 8.x or above, if you have a Swift project where you want to support iOS 7.x too, SCLAlertView is an ideal substitution.

用swift写的一个可以做动画的AlertView,你可以用它替换 UIAlertView 或者是 UIAlertController。苹果官方在 iOS 8.x 的时候开始弃用 UIAlertView ,如果你使用 Swift 开发项目,且想支持 iOS 7.x,SCLAlertView 可以满足你的需求。

 

Easy to use

Get Started - 开始使用

// Get started
SCLAlertView().showInfo("Important info", subTitle: "You are great")

Updating the alert view - 更新 alert view

let alertViewResponder: SCLAlertViewResponder = SCLAlertView().showSuccess("Hello World", subTitle: "This is a more descriptive text.") // Upon displaying, change/close view alertViewResponder.setTitle("New Title") // Rename title alertViewResponder.setSubTitle("New description") // Rename subtitle alertViewResponder.close() // Close view

Alternative alert types - 多种 alertView 的类型

SCLAlertView().showError("Hello Error", subTitle: "This is a more descriptive error text.") // Error
SCLAlertView().showNotice("Hello Notice", subTitle: "This is a more descriptive notice text.") // Notice
SCLAlertView().showWarning("Hello Warning", subTitle: "This is a more descriptive warning text.") // Warning
SCLAlertView().showInfo("Hello Info", subTitle: "This is a more descriptive info text.") // Info
SCLAlertView().showEdit("Hello Edit", subTitle: "This is a more descriptive info text.") // Edit

Raw call to showTitle() 

SCLAlertView().showTitle(
    title: "Congratulations", // Title of view
    subTitle: "Operation successfully completed.", // String of view duration: 2.0, // Duration to show before closing automatically, default: 0.0 completeText: "Done", // Optional button value, default: "" style: .Success // Styles - see below. colorStyle: 0xA429FF, colorTextButton: 0xFFFFFF )

Controls - 控制

Add buttons - 添加按钮

let alertView = SCLAlertView()
alertView.addButton("First Button", target:self, selector:Selector("firstButton")) alertView.addButton("Second Button") { println("Second button tapped") } alertView.showSuccess("Button View", subTitle: "This alert view has buttons")

Hide default close button - 隐藏默认的关闭按钮

let alertView = SCLAlertView()
alertView.showCloseButton = false
alertView.showSuccess("No button", subTitle: "You will have hard times trying to close me")

Add Text fields - 添加文本编辑框

// Add a text field
let alert = SCLAlertView()
let txt = alert.addTextField(title:"Enter your name") alert.addButton("Show Name") { println("Text value: \(txt.text)") } alert.showEdit("Edit View", subTitle: "This alert view shows a text box")

Alert View Styles - Alert View 的各种风格

enum SCLAlertViewStyle: Int {
    case Success, Error, Notice, Warning, Info, Edit, Wait
}

Installation 

安装

SCLAlertView is available through CocoaPods.

你可以通过 CocoaPods 安装 SCLAlertView。

To install add the following line to your Podfile:

添加下面一句话即可:

pod 'SCLAlertView'

 

Collaboration

I tried to build an easy to use API, while beeing flexible enough for multiple variations, but I'm sure there are ways of improving and adding more features, so feel free to collaborate with ideas, issues and/or pull requests.

 

Incoming improvements

  • More animations - 更多的动画类型
  • Performance tests

Has been developed initially for the Scroll Feed app

 

目录
相关文章
|
2月前
|
安全 IDE Swift
Swift
Swift
21 0
|
4月前
|
存储 算法 安全
【Swift专题】聊聊Swift中的属性
属性是面向对象语言中非常基础的语法特性,我们讲属性,实际上就是讲与类本身或类实例关联的数据。在面向对象的语言中,类作为重要的数据结构会封装数据与函数,类中的函数我们通常称其为方法,而数据则就是属性。
43 1
|
Swift
swift中使用NSClassFromString
swift中使用NSClassFromString
284 0
|
存储 测试技术 Swift
Swift-RealmSwift 的使用
Swift-RealmSwift 的使用
702 0
Swift-RealmSwift 的使用
|
存储 Swift
Swift中类的使用
Swift中类的使用
93 0
|
区块链 Swift
当我们在谈SWIFT时,到底在谈什么?
当我们在谈SWIFT时,到底在谈什么?
当我们在谈SWIFT时,到底在谈什么?
|
Swift 数据安全/隐私保护
Swift 简单总结
1. swift简单总结(一)—— 数据简单值和类型转换2. swift简单总结(二)—— 简单值和控制流3. swift简单总结(三)—— 循环控制和函数4.
1261 0
|
iOS开发
Swift 2.3升级到Swift 3.0小记
> 阿里云App从Swift 2.1开始使用Swift,随时不断的推进,现在所有的业务代码都用Swift编写。由于Swift 3.0语法上有诸多改变,所以从Swift 2.3升级到Swift 3.0是一件宜早不宜迟的事情。元旦期间抽了点时间做这个升级。 ### 外部依赖 * 目前开源社区对Swift 3.0支持是非常好的,我们依赖的开源组件最新版本都支持Swift 3.0了,所以并没有
1718 0