当前位置: 移动技术网 > 移动技术>移动开发>IOS > iOS 倒计时的一种实现

iOS 倒计时的一种实现

2018年12月13日  | 移动技术网移动技术  | 我要评论

1、view

[self performselectorinbackground:@selector(thread) withobject:nil];
- (void)thread
{
    for(int i=300;i>=0;i--)
    {
        _count = i;
        // 回调主线程
        [self performselectoronmainthread:@selector(mainthread) withobject:nil waituntildone:yes];
        sleep(1);
    }
}

// 此函数主线程执行
- (void)mainthread
{
    self.time.text=[nsstring stringwithformat:@"%d",_count];
    if (_count==0) {
        
    }
}

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网