modifying dynamically the duration of CAKeyframeAnimation

孤者浪人 提交于 2019-12-25 06:40:15

问题


In my code I create a CAKeyframeanimation with an infinite repeat count, add it to a specific CALayer. I would like to modify the duration (= the speed) of the animation while animating, without the need of restarting my animation. So when i click on a button, i get a duration that I can set for the animation. I have to remove the animation, create another one, and make it start to where i stopped it. The problem is that I can't seem to restart it from that point without making it loop from that point. If it were a rotation, it wouldn't be problematic but I use a translation.


So, I have 3 points, A, then B, then C, on a straight line. My translation goes from A to C, passing through B, and repeats itself infinitely. When i change the duration, at point B, I can only recreate a translation animation from B to C (which is not good), Or, i can recreate an animation from A to C with the new duration but it restarts from point A (which is no good either). Would you have any idea of how i can do what i want ? Thanks

来源:https://stackoverflow.com/questions/13286702/modifying-dynamically-the-duration-of-cakeyframeanimation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!