• 发送短信验证码按钮 定时器


    static int i = 29;
    @property(nonatomic,strong) NSTimer *timmer;//定时器
    - (void)sendNumber{
        NSLog(@"发送验证码");
        self.getTelephoneCodeBtn.enabled = NO;
        [self.getTelephoneCodeBtn setTitle:@"已发送" forState:UIControlStateDisabled];
        [self.getTelephoneCodeBtn setBackgroundColor:[UIColor grayColor]];
        //初始化定时器
        _timmer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(test:) userInfo:nil repeats:YES];
    }
    
    - (void)test:(NSTimer *)timmer{
        NSString *str = [NSString stringWithFormat:@"%d后重试",i];
        [self.getTelephoneCodeBtn setTitle:str forState:UIControlStateDisabled];
        i--;
        if (i == -1) {
            [timmer invalidate];
            self.getTelephoneCodeBtn.enabled = YES;
            [self.getTelephoneCodeBtn setTitle:@"发送验证码" forState:UIControlStateNormal];
            [self.getTelephoneCodeBtn setBackgroundColor:getColor(@"fa2671")];
            i = 29;
        }
    }
    //点击的按钮  初始化
    - (UIButton *)sendCodeButton
    {
        if (!_sendCodeButton) {
            _sendCodeButton = [[UIButton alloc]init];
            _sendCodeButton.backgroundColor = getColor(mainColor);
            [_sendCodeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [_sendCodeButton setTitle:@"发送验证码" forState:UIControlStateNormal];
            _sendCodeButton.titleLabel.font = DEF_FontSize_14;
            [_sendCodeButton addTarget:self action:@selector(sendNumber) forControlEvents:UIControlEventTouchUpInside];
        }
        return _sendCodeButton;
    }
  • 相关阅读:
    HDU 2955 Robberies
    CodeForces 429B Working out DP
    Lweb and String 超级大水题
    A water problem 大数取余。
    Danganronpa 水题。
    HDU 2018 DP
    Git分支管理
    linux相关操作命令
    项目部署相关命令(pm2)
    ubantu16.04安装sougou输入法
  • 原文地址:https://www.cnblogs.com/dujiahong/p/7407063.html
Copyright © 2020-2023  润新知