iOS如何封装倒计时按钮HLCountDownButton(hlcountdownbutton,ios,开发技术)

时间:2024-05-03 11:13:11 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

演示图

iOS如何封装倒计时按钮HLCountDownButton

iOS如何封装倒计时按钮HLCountDownButton

可选自定义属性

///样式,默认HLCountDownButtonTypeNormal@property(nonatomic,assign)IBInspectableNSIntegerhlTypeUI_APPEARANCE_SELECTOR;///是否可用,默认YES@property(nonatomic,assign)IBInspectableBOOLhlEnabledUI_APPEARANCE_SELECTOR;///正常标题,默认“获取验证码”@property(nonatomic,copy)IBInspectableNSString*normalTitleUI_APPEARANCE_SELECTOR;///重新获取标题,默认“获取验证码”@property(nonatomic,copy)IBInspectableNSString*againTitleUI_APPEARANCE_SELECTOR;///发送中标题格式,默认“%ds后获取”@property(nonatomic,copy)IBInspectableNSString*sendingTitleFormatUI_APPEARANCE_SELECTOR;///高亮颜色,默认0x4181FE@property(nonatomic,strong)IBInspectableUIColor*highlightedColorUI_APPEARANCE_SELECTOR;///非高亮颜色,默认0xd2d2d2@property(nonatomic,strong)IBInspectableUIColor*disabledColorUI_APPEARANCE_SELECTOR;///圆角半径,默认4@property(nonatomic,assign)IBInspectableCGFloatcornerRadiusUI_APPEARANCE_SELECTOR;///边框宽度,默认0.5@property(nonatomic,assign)IBInspectableCGFloatborderWidthUI_APPEARANCE_SELECTOR;///倒计时长,默认60s@property(nonatomic,assign)IBInspectableNSIntegercountDownSizeUI_APPEARANCE_SELECTOR;

3种样式选择

typedefNS_ENUM(NSInteger,HLCountDownButtonType){HLCountDownButtonTypeNormal,///<无背景,无边框HLCountDownButtonTypeOnlyLine,///<无背景,有边框HLCountDownButtonTypeOnlyBackground,///<有背景,无边框};

回调说明

__weaktypeof(self)weakSelf=self;self.countDownButton.startBlock=^(){//TODO点击了倒计时按钮,这里可进行发送验证码操作//[weakSelfsendCodeMsg];};

注意:点击了会有startBlock回调,就不要为HLCountDownButton添加点击Action

全局样式设置

如果您项目中多个地方使用到该组件,您可以全局设置样式,例在AppDelegate添加

[HLCountDownButtonappearance].highlightedColor=[UIColorredColor];

注意:代码 > appearance > interface builder,所以appearance设置的会覆盖在xib或storyboard中设置的属性,当然代码会覆盖appearance设置

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:iOS如何封装倒计时按钮HLCountDownButton的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:iOS如何实现手动和自动屏幕旋转下一篇:

6 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18