ios开发,发验证码倒计时按钮的实现
来源:互联网 发布:淘宝店铺花呗分期 编辑:程序博客网 时间:2024/06/06 03:49
#import "ViewController.h"
#define SEC 60
@interface ViewController ()
{
UIButton *_verifyBtn;
UILabel *_timeLab;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//获取验证码按钮
_verifyBtn = [UIButtonbuttonWithType:UIButtonTypeCustom];
_verifyBtn.frame =CGRectMake(0,0, 100, 45);
_verifyBtn.center =CGPointMake([UIScreenmainScreen].bounds.size.width/2.0, [UIScreen mainScreen].bounds.size.height/2.0);
[_verifyBtnsetBackgroundImage:[UIImageimageNamed:@"yanzhengma_02"]forState:UIControlStateNormal];
[_verifyBtnsetTitleColor:[UIColorwhiteColor] forState:UIControlStateNormal];
[_verifyBtnaddTarget:selfaction:@selector(verifyEvent)forControlEvents:UIControlEventTouchUpInside];
_verifyBtn.titleLabel.font = [UIFontsystemFontOfSize:17];
[self.viewaddSubview:_verifyBtn];
_timeLab = [[UILabelalloc] initWithFrame:CGRectMake(0,0, 100,45)];
_timeLab.backgroundColor = [UIColorclearColor];
_timeLab.textAlignment =NSTextAlignmentCenter;
_timeLab.font = [UIFontsystemFontOfSize:16];
_timeLab.textColor = [UIColorwhiteColor];
_timeLab.text =@"获取验证码";
[_verifyBtn addSubview:_timeLab];
}
- (void)verifyEvent
{
//启动倒计时
[selfperformSelector:@selector(reflashGetKeyBt:)withObject:[NSNumbernumberWithInt:SEC]afterDelay:0];
}
//倒数
- (void)reflashGetKeyBt:(NSNumber *)second
{
if ([second integerValue] ==0)
{
[_verifyBtnsetBackgroundImage:[UIImageimageNamed:@"yanzhengma_02"]forState:UIControlStateNormal];
_timeLab.text =@"获取验证码";
}
else
{
[_verifyBtnsetBackgroundImage:[UIImageimageNamed:@"yanzhengma_01"]forState:UIControlStateNormal];
int i = [second intValue];
_timeLab.text=[NSStringstringWithFormat:@"%i秒后重发",i];
[selfperformSelector:@selector(reflashGetKeyBt:)withObject:[NSNumbernumberWithInt:i-1]afterDelay:1];
}
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- ios开发,发验证码倒计时按钮的实现
- iOS开发中获取短信验证码倒计时按钮的实现
- iOS 短信验证码倒计时按钮的实现
- iOS 短信验证码倒计时按钮的实现
- iOS 短信验证码倒计时按钮的实现
- iOS 短信验证码倒计时按钮的实现
- iOS - 验证码,倒计时按钮
- 按钮倒计时的实现 iOS
- 获取短信验证码时的倒计时按钮实现
- 获取短信验证码时的倒计时按钮实现
- 获取短信验证码时的倒计时按钮实现
- 获取验证码按钮,点击后倒计时功能的实现
- 使用rxjava2实现验证码重新发送按钮的倒计时
- jquery 实现验证码倒计时 点击按钮后倒计时效果
- 验证码倒计时按钮
- Android发送验证码的倒计时按钮
- iOS发送验证码倒计时功能的实现
- iOS短信验证码倒计时Button的实现
- C++ 常用宏总结
- The method of type must override a superclass method解决方式
- XSS扫描系统原理
- window方法大全
- Git详解之九:Git内部原理
- ios开发,发验证码倒计时按钮的实现
- Unity3D游戏开发之使用disunity提取Unity3D游戏资源
- Appium源码分析(4)-控制器模块
- LWM2M 简介
- mysql 动态执行sql
- java中自动装箱和自动拆箱
- 蒋鑫:为什么 Git 比 SVN 好
- c# Application.DoEvents
- MOD09A1数据与Landsat 4/5 TM波段的对应关系