SCLAlertView-Swift

SCLAlertView是一款用Swift编写的可动画化的AlertView组件,可作为UIAlertView或UIAlertController的替代品,尤其适用于需要支持iOS7.x的Swift项目。提供多种样式如成功、错误等,并支持自定义按钮和文本编辑框。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值