Latest | 1.0.1 |
---|---|
Homepage | https://github.com/dingfude2008/DFCountDownButton |
License | MIT |
Platforms | ios 7.0 |
Frameworks | Foundation |
Authors |
DFCountDownButton,继承UIButton,实现IOS倒计时按钮,用于注册等发送验证码的时候进行倒计时操作
DFCountDownButton, subclassing UIButton implementation iOS countdown button, register with sending the verification code and countdown
Installation
Installation with CocoaPods
platform :ios
pod 'DFCountDownButton'
Manually
Copy DFCountDownButtonn.h DFCountDownButtonn.m in DFCountDownButton/ to your project.
Usage
Code
DFCountDownButton *_dfCountDownButton;
_dfCountDownButton = [[DFCountDownButton alloc] init];
_dfCountDownButton.frame = CGRectMake(106, 170, 120, 32);
_dfCountDownButton.backgroundColor = [UIColor redColor];
[_dfCountDownButton setTitle:@"开始" forState:UIControlStateNormal];
[self.view addSubview:_dfCountDownButton];
__weak typeof(self) weakSelf = self;
_dfCountDownButton.countDownButtonBlock = ^(DFCountDownButton *sender,NSInteger tag){
sender.enabled = NO;
[sender startCountDownWithSecond:10];
sender.countDownChanging = ^NSString *(DFCountDownButton *countDownButton, NSUInteger second){
return [NSString stringWithFormat:@"剩余%zd秒",second];
};
sender.countDownFinished = ^NSString *(DFCountDownButton *countDownButton){
countDownButton.enabled = YES;
__strong typeof(self) self = weakSelf;
NSLog(@"%@", self);
return @"点击重新获取";
};
};
xib
@property (weak, nonatomic) IBOutlet DFCountDownButton *countDownXib;
- (IBAction)countDownXibTouched:(DFCountDownButton*)sender {
__weak typeof(self) weakSelf = self;
sender.enabled = NO;
[sender startCountDownWithSecond:10];
sender.countDownChanging = ^NSString *(DFCountDownButton *countDownButton,NSUInteger second) {
NSString *title = [NSString stringWithFormat:@"剩余%zd秒",second];
return title;
};
sender.countDownFinished = ^NSString *(DFCountDownButton *countDownButton) {
countDownButton.enabled = YES;
__strong typeof(self) self = weakSelf;
NSLog(@"%@", self);
return @"点击重新获取";
};
}
License
This code is distributed under the terms and conditions of the MIT license.
Demo
Latest podspec
{ "name": "DFCountDownButton", "version": "1.0.1", "summary": "DFCountDownButton, subclassing UIButton implementation iOS countdown button, register with sending the verification code and countdown", "homepage": "https://github.com/dingfude2008/DFCountDownButton", "license": "MIT", "authors": { "dingfude2008": "[email protected]" }, "source": { "git": "https://github.com/dingfude2008/DFCountDownButton.git", "tag": "1.0.1" }, "source_files": "DFCountDownButton/DFCountDownButton/DFCountDownButton.{h,m}", "platforms": { "ios": "7.0" }, "frameworks": "Foundation" }
Fri, 10 Feb 2017 06:40:04 +0000