-(void)getCodeSuccess
{
self.codeButton.enabled = NO;
self.number = 59;
self.timmer = [NSTimer timerWithTimeInterval:1.0f target:self selector:@selector(changeGetCodeButtonTitle) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:self.timmer forMode:NSRunLoopCommonModes];
[self.timmer fire];
self.touched = NO;
}
//更换,获取验证码按钮标题
- (void)changeGetCodeButtonTitle
{
self.codeButton.titleLabel.text = [NSString stringWithFormat:@"%d秒后重试",(self.number)];
[self.codeButton setTitle:[NSString stringWithFormat:@"%d秒后重试",(self.number)] forState:UIControlStateDisabled];
self.number--;
if (self.number == 0) {
[self.timmer invalidate];
self.timmer = nil;
[self.codeButton setTitle:@"重新获取" forState:UIControlStateNormal];
self.codeButton.enabled = YES;
}
}
网友评论