封装了 NSTimer 的 UIButton
创建 HGTimerButton 对象,类似于创建 UIButton 对象
HGTimerButton *timerButton = [HGTimerButton buttonWithType:UIButtonTypeCustom];
[timerButton setTitle:@"获取验证码" forState:UIControlStateNormal];
timerButton.titleLabel.font = [UIFont systemFontOfSize:16];
[timerButton addTarget:self action:@selector(timerButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:timerButton];
设置倒计时提示
timerButton.disabledTitleFormat = @"重新获取(&s)";
调用 start
方法开始
[timerButton start];
MIT