IOS 卡片式倒计时

2021-01-27  本文已影响0人  菠萝吹雪xs

需要做一个类似这种的倒计时


WeChat986c2396f2c84af043c86f046a558a4b.png

这种不难,但是比较烦,因为要把时分秒都分开,写好多label来存放
倒计时还是通过计时器来实现

- (void)timerClick
{
  
    self.currentTime -=1;
    [self calculation];
    
    if (self.currentTime==0) {
        [self stopNow];
    }
}

后来又考虑到有的需要显示天数,前面就又加了一个,并且用bool来区分是否显示

-(XSTimerTextView *)toptimerView{
    if (!_toptimerView) {
        _toptimerView=[XSTimerTextView new];
        _toptimerView.calculationTime=3600*48+20;
        _toptimerView.showDayBool=YES;//yes显示天数,no只显示小时
        _toptimerView.numberBackgroudColor=[UIColor greenColor];
        _toptimerView.sepBackgroupColor=[UIColor blueColor];
        _toptimerView.labelColor=[UIColor blackColor];
        _toptimerView.sepColor=[UIColor whiteColor];
        _toptimerView.textFont=17;
        _toptimerView.sepFont=15;
    }
    return _toptimerView;
}
B63AB875-234C-47E0-A722-F0A2A8EF40C5.png

demo已经上传GitHub,需要的可以自行下载并且根据需求修改
https://github.com/xinsun001/XSTimerCardView

上一篇 下一篇

猜你喜欢

热点阅读