您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“iOS如何封裝倒計時按鈕HLCountDownButton”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“iOS如何封裝倒計時按鈕HLCountDownButton”吧!
/// 樣式,默認HLCountDownButtonTypeNormal @property (nonatomic, assign) IBInspectable NSInteger hlType UI_APPEARANCE_SELECTOR; /// 是否可用,默認YES @property (nonatomic, assign) IBInspectable BOOL hlEnabled UI_APPEARANCE_SELECTOR; /// 正常標(biāo)題,默認“獲取驗證碼” @property (nonatomic, copy) IBInspectable NSString *normalTitle UI_APPEARANCE_SELECTOR; /// 重新獲取標(biāo)題,默認“獲取驗證碼” @property (nonatomic, copy) IBInspectable NSString *againTitle UI_APPEARANCE_SELECTOR; /// 發(fā)送中標(biāo)題格式,默認“%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; /// 邊框?qū)挾?,默認0.5 @property (nonatomic, assign) IBInspectable CGFloat borderWidth UI_APPEARANCE_SELECTOR; /// 倒計時長,默認60s @property (nonatomic, assign) IBInspectable NSInteger countDownSize UI_APPEARANCE_SELECTOR;
typedef NS_ENUM(NSInteger, HLCountDownButtonType) { HLCountDownButtonTypeNormal, ///< 無背景,無邊框 HLCountDownButtonTypeOnlyLine, ///< 無背景,有邊框 HLCountDownButtonTypeOnlyBackground, ///< 有背景,無邊框 };
__weak typeof(self) weakSelf = self; self.countDownButton.startBlock = ^(){ // TODO 點擊了倒計時按鈕,這里可進行發(fā)送驗證碼操作 // [weakSelf sendCodeMsg]; };
注意:點擊了會有startBlock
回調(diào),就不要為HLCountDownButton
添加點擊Action
了
如果您項目中多個地方使用到該組件,您可以全局設(shè)置樣式,例在AppDelegate
添加
[HLCountDownButton appearance].highlightedColor = [UIColor redColor];
注意:代碼
> appearance
> interface builder
,所以appearance設(shè)置的會覆蓋在xib或storyboard中設(shè)置的屬性,當(dāng)然代碼
會覆蓋appearance
設(shè)置
到此,相信大家對“iOS如何封裝倒計時按鈕HLCountDownButton”有了更深的了解,不妨來實際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。