swift分装的倒计时按钮
2016-04-19 15:29
330 查看
///
这个类的说明
/*
* 倒计时按钮的分装
*
*
*
*/
import UIKit
class XCTools: NSObject {
// 定时器
var myTimer:NSTimer?
///
倒计时按钮
func sendCode(button:UIButton,color:UIColor) ->
Void {
var i = 60
button.setTitle("重发(60)", forState: UIControlState.Disabled)
button.backgroundColor=UIColor.lightGrayColor()
button.enabled=false
myTimer = NSTimer.bk_scheduledTimerWithTimeInterval(1, block: { (a)
in
i -= 1
button.setTitle(String(format: "重发(%d)",i), forState: UIControlState.Disabled)
button.backgroundColor=UIColor.lightGrayColor()
if i ==
0 {
self.myTimer?.invalidate()
button.enabled=true
button.backgroundColor=color
}
}, repeats: true)
}
}
这个类的说明
/*
* 倒计时按钮的分装
*
*
*
*/
import UIKit
class XCTools: NSObject {
// 定时器
var myTimer:NSTimer?
///
倒计时按钮
func sendCode(button:UIButton,color:UIColor) ->
Void {
var i = 60
button.setTitle("重发(60)", forState: UIControlState.Disabled)
button.backgroundColor=UIColor.lightGrayColor()
button.enabled=false
myTimer = NSTimer.bk_scheduledTimerWithTimeInterval(1, block: { (a)
in
i -= 1
button.setTitle(String(format: "重发(%d)",i), forState: UIControlState.Disabled)
button.backgroundColor=UIColor.lightGrayColor()
if i ==
0 {
self.myTimer?.invalidate()
button.enabled=true
button.backgroundColor=color
}
}, repeats: true)
}
}
相关文章推荐
- Swift UIFont 传入字体name和size问题
- Swift 下debug状态打印log
- Swift笔记:方法
- 自定义presentViewController的转场动画(Swift)
- Swift PageControl
- Swift -- 2.基本数据类型
- Swift UIDatePikcer
- swift-元组的基本用法
- Apple Swift编程语言入门教程
- swift和oc混编
- 趋势!SWIFT必定会被区块链技术取…
- SWIFT:必须承认区块链在金融行业…
- Swift提出“区块链路线图”,谋求突…
- 消息人士称,Google考虑将Swift作为安卓的主要编程语言
- swift 属性的几个写法
- 更简单地进行Auto Layout--SnapKit 支持swift
- Swift学习笔记(三)
- Swift 闭包(Closures)传值
- swift(02)基础学习
- Swift的期待