modifying dynamically the duration of CAKeyframeAn

2019-09-13 08:24发布

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

0条回答
登录 后发表回答