Latest 1.0.3
Homepage https://github.com/xuhonggui/HGTimerButton
License MIT
Platforms ios 8.0, requires ARC
Authors

封装NSTimer的UIButton,依赖HWWeakTimer库,避免NSTimer强引用导致的内存泄漏,支持纯代码及xib:


How to Use

使用CocoaPods

pod 'HGTimerButton'

手动导入

HGTimerButtonHWWeakTimer文件夹中所有源代码拽入项目中,导入头文件import "HGTimerButton.h"

示例:

创建对象

HGTimerButton *timerButton = [HGTimerButton buttonWithType:UIButtonTypeCustom];
timerButton.frame = CGRectMake(40, CGRectGetHeight(self.view.frame)/2 - 50, CGRectGetWidth(self.view.frame) - 80, 40);
[timerButton setTitle:@"获取验证码" forState:UIControlStateNormal];
[timerButton setBackgroundColor:[UIColor colorWithRed:0/255.0 green:174.0/255.0 blue:235.0/255.0 alpha:1.0]];
[timerButton addTarget:self action:@selector(timerButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:timerButton];

设置开始时间:

timerButton.startCount = 30;

设置倒计时提示:

timerButton.disabledTitleFormat = @"重新获取(&s)";

调用start方法开始:

[timerButton start];

License

MIT

Latest podspec

{
    "name": "HGTimerButton",
    "version": "1.0.3",
    "summary": "a custom UIButton that contains NSTimer",
    "homepage": "https://github.com/xuhonggui/HGTimerButton",
    "license": "MIT",
    "authors": {
        "xuhonggui": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/xuhonggui/HGTimerButton.git",
        "tag": "1.0.3"
    },
    "source_files": "*.{h,m}",
    "requires_arc": true,
    "subspecs": [
        {
            "name": "HWWeakTimer",
            "dependencies": {
                "HWWeakTimer": []
            }
        }
    ]
}

Pin It on Pinterest

Share This