倒计时按钮,使用 GCD,您可以在代码或 XIB 中使用。
使用 GCD 实现倒计时 Button,可以在多线程中使用,无需担心循环引用。
您可以使用纯代码或 Xib 创建。
//设置变化过程中Button的title,如
[SDCountDownButton setChangingFormatter:^NSString *(NSTimeInterval second) {
return [NSString stringWithFormat:@"%.0lf S", second];
}];
//设置倒计时结束后的title
[self.one setFinishedString:@"涨涨涨"];
//倒计时结束后的回调
[SDCountDownButton completed:^{
NSLog(@"The count down is over.");
}];