欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

iOS如何獲取短信驗(yàn)證碼倒計(jì)時(shí)

這篇文章將為大家詳細(xì)講解有關(guān)iOS如何獲取短信驗(yàn)證碼倒計(jì)時(shí),小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新新互聯(lián),憑借十年的網(wǎng)站建設(shè)、做網(wǎng)站經(jīng)驗(yàn),本著真心·誠心服務(wù)的企業(yè)理念服務(wù)于成都中小企業(yè)設(shè)計(jì)網(wǎng)站有1000+案例。做網(wǎng)站建設(shè),選創(chuàng)新互聯(lián)公司。

方法一:

網(wǎng)上用的很多的一種,不多說,直接上代碼.

-(void)startTime{
  __block int timeout= 60; //倒計(jì)時(shí)時(shí)間
  dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
  dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒執(zhí)行
  dispatch_source_set_event_handler(_timer, ^{
    if(timeout<=0){ //倒計(jì)時(shí)結(jié)束,關(guān)閉
      dispatch_source_cancel(_timer);
      dispatch_async(dispatch_get_main_queue(), ^{
        [self.getIdentifyCodeBt setTitle:@"獲取驗(yàn)證碼" forState:UIControlStateNormal];
        self.getIdentifyCodeBt.userInteractionEnabled = YES;
        [self.getIdentifyCodeBt setTitleColor:THEME_RED forState:UIControlStateNormal];
        self.getIdentifyCodeBt.backgroundColor = [UIColor whiteColor];
        self.getIdentifyCodeBt.layer.borderColor = THEME_RED.CGColor;
      });
    }else{
      dispatch_async(dispatch_get_main_queue(), ^{

        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:1];
        [self.getIdentifyCodeBt setTitle:[NSString stringWithFormat:@"%zd秒后失效",timeout] forState:UIControlStateNormal];
        [self.getIdentifyCodeBt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.getIdentifyCodeBt.backgroundColor = [UIColor lightGrayColor];
        self.getIdentifyCodeBt.layer.borderColor = [UIColor clearColor].CGColor;
        self.getIdentifyCodeBt.clipsToBounds = YES;
        [UIView commitAnimations];
        self.getIdentifyCodeBt.userInteractionEnabled = NO;
      });
      timeout--;
    }
  });
  dispatch_resume(_timer);

}

到時(shí)直接調(diào)用就可以了。

方法二:利用分類

給UIButton新建一個(gè)分類

.h文件如下

#import <UIKit/UIKit.h>

@interface UIButton (XSCountDown)
- (void)xs_beginCountDownWithDuration:(NSTimeInterval)duration;
- (void)xs_stopCountDown;
@end

.m文件如下

#import "UIButton+XSCountDown.h"

#import "ThemeColor.h"
static NSTimer *_countTimer;
static NSTimeInterval _count;
static NSString *_title;

@implementation UIButton (XSCountDown)

- (void)xs_beginCountDownWithDuration:(NSTimeInterval)duration {
  _title = self.titleLabel.text;
  _count = duration;
  _countTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(xs_updateTitle) userInfo:nil repeats:YES];
  [[NSRunLoop mainRunLoop] addTimer:_countTimer forMode:NSRunLoopCommonModes];
  self.userInteractionEnabled = NO;

   [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  self.backgroundColor = [UIColor lightGrayColor];
  self.layer.borderColor = [UIColor clearColor].CGColor;
  self.clipsToBounds = YES;
}

- (void)xs_stopCountDown {
  [_countTimer invalidate];
  _countTimer = nil;
  _count = 60.0;
  [self setTitle:_title forState:UIControlStateNormal];
  self.userInteractionEnabled = YES;
}

- (void)xs_updateTitle {
  NSString *countString = [NSString stringWithFormat:@"%lis 后失效", (long)_count - 1];
  self.userInteractionEnabled = NO;
  [self setTitle:countString forState:UIControlStateNormal];
  if (_count-- <= 1.0) {
    [self xs_stopCountDown];
    [self setTitleColor:THEME_RED forState:UIControlStateNormal];
    self.backgroundColor = [UIColor whiteColor];
    self.layer.borderColor = THEME_RED.CGColor;
  }

}

@end

然后在controller里直接調(diào)用分類.h文件里的方法就ok了

[self.verifyBt xs_beginCountDownWithDuration:60.0];

關(guān)于“iOS如何獲取短信驗(yàn)證碼倒計(jì)時(shí)”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。

網(wǎng)頁名稱:iOS如何獲取短信驗(yàn)證碼倒計(jì)時(shí)
分享URL:http://www.aaarwkj.com/article42/gopoec.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、網(wǎng)站收錄、網(wǎng)站建設(shè)、Google、定制網(wǎng)站、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)
最新欧美精品一区二区| 内射极品美女在线观看| 欧美成人精品三级在线网站| 日本一区二区三区播放| 亚洲av永久精品桃色| 男女啪啪国产精品视频| av福利一区二区三区| 日韩精品诱惑一区二区| 视频一区日本视频二区| 欧美精品一区二区久久不卡| 国产一区二区不卡在线播放 | 久久久久久国产精彩视频| 白嫩少妇情久久密月久久| 国产成人亚洲欧美激情| 人妻少妇亚洲中文字幕| 粉嫩欧美一区二区三区| 欧美三级欧美一级视频看| 亚洲乱色一区二区三区丝袜| 男人的av天堂东京热| 18禁黄网站禁片免费视频| 欧美久久久久综合一区| 国产精品久久一国产精品| 国产女主播福利在线播放| 国产白浆一区二区视频| 四虎国产精品久久久久久网址| 中文字幕女同系列av厨房| 97视频精品免费观看| 亚洲天堂国产成人精品| 天堂社区人妻在线亚洲| 欧美老熟妇精品一区二区| 亚洲精品日本一区二区| 色一区欧美一区亚洲一区| 日韩精品一区福利合集| 欧美人妻不卡一区二区久久| 亚洲婷婷综合久久一区二区| 中字幕人妻一区二区三区| 国产日韩欧美另类专区| 一区二区三区欧美小黄片| 国产自拍在线视频精品| 韩国成人伦理片在线观看| 国产av不卡二区三区|