標籤:io ar color os sp for on div art
- timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
- //倒計時方法驗證碼實現倒計時60秒,60秒後按鈕變換開始的樣子
- -(void)timerFireMethod:(NSTimer *)theTimer {
- if (seconds == 1) {
- [theTimer invalidate];
- seconds = 60;
- [validCodeBtn_ setTitle:@"擷取驗證碼" forState: UIControlStateNormal];
- [validCodeBtn_ setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [validCodeBtn_ setEnabled:YES];
- }else{
- seconds--;
- NSString *title = [NSString stringWithFormat:MSG_DYNAMIC_CODE_WAIT,seconds];
- [validCodeBtn_ setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
- [validCodeBtn_ setEnabled:NO];
- [validCodeBtn_ setTitle:title forState:UIControlStateNormal];
- }
- }
- //如果登陸成功,停止驗證碼的倒數,
- - (void)releaseTImer {
- if (timer) {
- if ([timer respondsToSelector:@selector(isValid)]) {
- if ([timer isValid]) {
- [timer invalidate];
- seconds = 60;
- }
- }
- }
- }
ios 簡單的倒計時驗證碼數秒過程實現