美文网首页
分钟小时倒计时

分钟小时倒计时

作者: 楠Y | 来源:发表于2017-04-22 16:18 被阅读14次

productState.text = [NSString stringWithFormat:@"代付款 %d分%d秒",30,0];

productState.textColor = MAIN_COLOR;

if (_timer==nil) {

__block int timeout = 2 * 60; //倒计时时间

if (timeout!=0) {

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

_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); //每秒执行

dispatch_source_set_event_handler(_timer, ^{

if(timeout<=0){ //倒计时结束,关闭

dispatch_source_cancel(_timer);

_timer = nil;

dispatch_async(dispatch_get_main_queue(), ^{

productState.text = @"萨比完事了都";

});

}else{

int days = (int)(timeout/(3600*24));

int hours = (int)((timeout-days*24*3600)/3600);

int minute = (int)(timeout-days*24*3600-hours*3600)/60;

int second = timeout-days*24*3600-hours*3600-minute*60;

dispatch_async(dispatch_get_main_queue(), ^{

productState.text = [NSString stringWithFormat:@"代付款 %d分%d秒",minute,second];

});

timeout--;

}

});

dispatch_resume(_timer);

}

}

相关文章

  • 分钟小时倒计时

    productState.text = [NSString stringWithFormat:@"代付款 %d分%...

  • vue中使用倒计时

    短信验证码60s倒计时 十五分钟倒计时 五分钟倒计时 结束之后会再加五分钟倒计时 跳转页面不会重新开始

  • 倒计时案例

    倒计时代码的步骤: 1、首先生成一个模板 倒计时:xxx天xx小时xx分钟xx秒 2、书写模板的样式 3、js逻辑...

  • 2020第一季度01-“自知”>14/90<

    2020-01-14-21:50(倒计时30 分钟) 日常: 今日睡眠:23:39~>07:15;07小时36分;...

  • 2020第一季度01-“自知”>15/90<

    2020-01-15-21:27(倒计时30 分钟) 日常: 今日睡眠:23:57~>07:10;07小时13分;...

  • 2020第一季度01-“自知”>13/90<

    2020-01-13-21:05(倒计时30 分钟) 日常: 今日睡眠:00:35~>07:11;06小时36分;...

  • 1小时倒计时

    倒计时 目前我们内部用的比较多的倒计时:一个小时的倒计时、12个小时的倒计时。 examinePassTime:审...

  • 2020第一季度-“自知02”>38/90<

    2020-02-07-21:57(倒计时30 分钟,1000+字) 今天早上比昨天早起了2小时,今天成功8...

  • 距2020年春节还有…

    距2020年春节还有 ?天 ?小时 ?分钟 ?秒下面我们来自己做一个倒计时吧! 首先在上面,我们封装...

  • 1219晨读打卡长头投基金特训营

    番茄工作法 1.倒计时法(核心)任务分解成为半小时左右,每25分钟集中精力,然后休息五分钟。 2.合理规划任务和分...

网友评论

      本文标题:分钟小时倒计时

      本文链接:https://www.haomeiwen.com/subject/rwpszttx.html