iOS经典讲解之倒计时按钮JKCountDownButton的使用
来源:互联网 发布:java窗口程序实例 编辑:程序博客网 时间:2024/05/22 04:27
作者:Loving_iOS
转载请标明出处:http://blog.csdn.net/loving_ios/article/details/50786890
下载倒计时按钮JKCountDownButton 代码传送门
JKCountDownButton,实现iOS倒计时按钮,常用于注册等发送验证码的时候进行倒计时操作。
下面介绍其用法:
代码方式创建:
JKCountDownButton *button = [JKCountDownButton buttonWithType:UIButtonTypeCustom];button.frame = CGRectMake(100, 100, 100, 100);[button setTitle:@"获取验证码" forState:UIControlStateNormal];button.backgroundColor = [UIColor blueColor];[self.view addSubview:button]; [button addToucheHandler:^(JKCountDownButton*sender, NSInteger tag) { sender.enabled = NO; [sender startWithSecond:10.0]; [sender didChange:^NSString *(JKCountDownButton *countDownButton,int second) { NSString *title = [NSString stringWithFormat:@"剩余%d秒",second]; return title; }]; [sender didFinished:^NSString *(JKCountDownButton *countDownButton, int second) { countDownButton.enabled = YES; return @"点击重新获取"; }]; }];用拖控件方式创建:首先你要button继承JKCountDownButton类,type 设置成custom
@property (weak, nonatomic) IBOutlet JKCountDownButton *button; - (IBAction)countDown:(JKCountDownButton*)sender {sender.enabled = NO;//button type要 设置成custom 否则会闪动[sender startWithSecond:10.0]; [sender didChange:^NSString *(JKCountDownButton *countDownButton,int second) { NSString *title = [NSString stringWithFormat:@"剩余%d秒",second]; return title;}];[sender didFinished:^NSString *(JKCountDownButton *countDownButton, int second) { countDownButton.enabled = YES; return @"点击重新获取"; }];}
效果图:
1 0
- iOS经典讲解之倒计时按钮JKCountDownButton的使用
- iOS经典讲解之实现扫描二维码ZBarSDK的使用
- iOS经典讲解之UIAlertView的使用技巧
- iOS经典讲解之cocoapods的安装使用
- iOS经典讲解之Socket使用教程
- 按钮倒计时的实现 iOS
- iOS经典讲解之百度地图的使用及案例(iOS地图SDK)
- iOS经典讲解之百度地图的使用及案例(iOS地图SDK)
- iOS 分类之按钮倒计时UIButton+CountDown
- iOS经典讲解之UICollectionView
- iOS经典讲解之NSUserDefaults
- iOS经典讲解之使用instruments检测内存
- iOS经典讲解之NSTimer、CADisplayLink、GCD三种定时器的使用
- IOS按钮倒计时
- iOS按钮倒计时
- 倒计时按钮,iOS
- iOS 倒计时按钮
- iOS 倒计时按钮
- 初学opengl(二)画散点图
- Python - access network
- js之事件冒泡和事件捕获详细介绍
- python实现网络爬虫
- 涨姿势!设计中的透视感与深度感
- iOS经典讲解之倒计时按钮JKCountDownButton的使用
- Palindrome Number
- 架构基础3-网站的高可用
- 基于近邻用户协同过滤算法的音乐推荐系统
- Unity3D-启动unity事件,切换平台监听
- POJ 1002
- Python+Scrapy+Redis+Mongodb 环境安装
- oracle 函数
- 解决Android Genymotion模拟器library "/system/lib/libhoudini.so" not found报错问题