{
int sum;
sum=60;
}
@property (nonatomic , strong) NSTimer *timer;//用于重新发送验证码按钮上倒计时
#pragma mark -- 定时器懒加载
- (NSTimer *)timer{
if (!_timer) {
_timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(cutdownTime) userInfo:nil repeats:YES];
[_timer setFireDate:[NSDate distantFuture]];
}
return _timer;
}
//定时器回调方法
- (void)cutdownTime{
_sum -- ;
NSString *buttonTitle = @"";
if (_sum >= 0) {
buttonTitle = [NSString stringWithFormat:@"%ds再次发送",_sum];
}else{
buttonTitle = @"再次发送";
YZMButton.enabled = YES;
[YZMButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[self.timer invalidate];//销毁定时器
self.timer = nil;
}
[YZMButton setTitle:buttonTitle forState:UIControlStateNormal];
}