美文网首页
UICountingLabel源码分析

UICountingLabel源码分析

作者: iOS白水 | 来源:发表于2019-06-07 09:13 被阅读0次

概述:就是金融数字滚动动画

1.CADisplayLink做定时器
preferredFramesPerSecond=1默认每秒运行60次,=2每秒运行30次。
NSTimer与CADisplayLink区别
NSTimer的精确度就显得低了点,比如NSTimer的触发时间到的时候,runloop如果在阻塞状态,触发时间就会推迟到下一个runloop周期。
CADisplayLink 场景单一,适合UI动画、界面刷新。

2.计算
特效:通过代理实现多种特效,代理函数是通过powf(x,y)去控制
timeIntervalSinceReferenceDate 到2001-1-1 的秒数

totalTime = Duration (总共时间)
progress=当前-lastDate

CGFloat percent = self.progress / self.totalTime;
self.startingValue + (updateVal * (self.destinationValue - self.startingValue))
通过上面 计算precent ,再推倒真实的值

参见iOS常用的c函数
https://www.cnblogs.com/sunjianfei/p/5509278.html

https://github.com/dataxpress/UICountingLabel

相关文章

网友评论

      本文标题:UICountingLabel源码分析

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