• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

SCLAlertView-Swift

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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
SCLAlertView().showInfo("Important info", subTitle: "You are great")

更新 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

多种 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
)

控制

添加按钮

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")

隐藏默认的关闭按钮

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

添加文本编辑框

// 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 的各种风格

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

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
swift学习(三)(面向对象基础)发布时间:2022-07-13
下一篇:
CoreLocation进行定位(Swift版)发布时间:2022-07-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap