本篇内容主要讲解“iOS如何封装倒计时按钮HLCountDownButton”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“iOS如何封装倒计时按钮HLCountDownBut
本篇内容主要讲解“iOS如何封装倒计时按钮HLCountDownButton”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“iOS如何封装倒计时按钮HLCountDownButton”吧!
演示图
可选自定义属性
/// 样式,默认HLCountDownButtonTypeNormal @property (nonatomic, assign) IBInspectable NSInteger hlType UI_APPEARANCE_SELECTOR; /// 是否可用,默认YES @property (nonatomic, assign) IBInspectable BOOL hlEnabled UI_APPEARANCE_SELECTOR; /// 正常标题,默认“获取验证码” @property (nonatomic, copy) IBInspectable NSString *normalTitle UI_APPEARANCE_SELECTOR; /// 重新获取标题,默认“获取验证码” @property (nonatomic, copy) IBInspectable NSString *againTitle UI_APPEARANCE_SELECTOR; /// 发送中标题格式,默认“%ds 后获取” @property (nonatomic, copy) IBInspectable NSString *sendingTitleFormat UI_APPEARANCE_SELECTOR; /// 高亮颜色,默认0x4181FE @property (nonatomic, strong) IBInspectable UIColor *highlightedColor UI_APPEARANCE_SELECTOR; /// 非高亮颜色,默认0xd2d2d2 @property (nonatomic, strong) IBInspectable UIColor *disabledColor UI_APPEARANCE_SELECTOR; /// 圆角半径,默认4 @property (nonatomic, assign) IBInspectable CGFloat cornerRadius UI_APPEARANCE_SELECTOR; /// 边框宽度,默认0.5 @property (nonatomic, assign) IBInspectable CGFloat borderWidth UI_APPEARANCE_SELECTOR; /// 倒计时长,默认60s @property (nonatomic, assign) IBInspectable NSInteger countDownSize UI_APPEARANCE_SELECTOR;
3种样式选择
typedef NS_ENUM(NSInteger, HLCountDownButtonType) { HLCountDownButtonTypeNormal, ///< 无背景,无边框 HLCountDownButtonTypeOnlyLine, ///< 无背景,有边框 HLCountDownButtonTypeOnlyBackground, ///< 有背景,无边框 };
回调说明
__weak typeof(self) weakSelf = self; self.countDownButton.startBlock = ^(){ // TODO 点击了倒计时按钮,这里可进行发送验证码操作 // [weakSelf sendCodeMsg]; };
注意:点击了会有startBlock
回调,就不要为HLCountDownButton
添加点击Action
了
全局样式设置
如果您项目中多个地方使用到该组件,您可以全局设置样式,例在AppDelegate
添加
[HLCountDownButton appearance].highlightedColor = [UIColor redColor];
注意:代码
> appearance
> interface builder
,所以appearance设置的会覆盖在xib或storyboard中设置的属性,当然代码
会覆盖appearance
设置
到此,相信大家对“iOS如何封装倒计时按钮HLCountDownButton”有了更深的了解,不妨来实际操作一番吧!这里是恰卡网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
本站部分文章来自网络或用户投稿,如无特殊说明或标注,均为本站原创发布。涉及资源下载的,本站旨在共享仅供大家学习与参考,如您想商用请获取官网版权,如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。