这个动画效果是从IOS7开始有的,个人觉得动画效果的用户体验很好,用起来也方便,但是这里面的dampingRatio和velocity涉及到物理力学的知识,比较难理解和计算,只能通过Demo试验来理解它所代表的意思。通过形象生动的比喻来理解它。
附上原英文文档解释
/* Performs animations using a timing curve described by the motion of a spring. When dampingRatio is 1, the animation will smoothly decelerate to its final model values without oscillating. Damping ratios less than 1 will oscillate more and more before coming to a complete stop. You can use the initial spring velocity to specify how fast the object at the end of the simulated spring was moving before it was attached. It’s a unit coordinate system, where 1 is defined as travelling the total animation distance in a second. So if you’re changing an object’s position by 200pt in this animation, and you want the animation to behave as if the object was moving at 100pt/s before the animation started, you’d pass 0.5. You’ll typically want to pass 0 for the velocity. */
其他参数不再介绍
dampingRatio(阻尼系数)
范围 0~1 当它设置为1时,动画是平滑的没有振动的达到静止状态,越接近0 振动越大
velocity (弹性速率)
就是形变的速度,从视觉上看可以理解弹簧的形变速度,到动画结束,该速度减为0,所以,velocity速度越大,那么形变会越快,当然在同等时间内,速度的变化(就是速率)也会越快,因为速度最后都要到0。
如果不明白可以自己手写Demo进行比较
本文介绍了iOS动画中阻尼系数(dampingRatio)与弹性速率(velocity)的概念及应用。通过生动的比喻帮助理解这两个参数如何影响动画效果,并提供了官方文档的解释。
4481

被折叠的 条评论
为什么被折叠?



