How to identify CAAnimation within the animationDidStop delegate?

后端 未结 10 2204
梦毁少年i
梦毁少年i 2020-11-28 18:26

I had a problem where I had a series of overlapping CATransition / CAAnimation sequences, all of which I needed to perform custom operations when the animations stopped, but

10条回答
  •  难免孤独
    2020-11-28 19:08

    To make explicit what's implied from above (and what brought me here after a few wasted hours): don't expect to see the original animation object that you allocated passed back to you by

     - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)flag 
    

    when the animation finishes, because [CALayer addAnimation:forKey:] makes a copy of your animation.

    What you can rely on, is that the keyed values you gave to your animation object are still there with equivalent value (but not necessarily pointer equivalence) in the replica animation object passed with the animationDidStop:finished: message. As mentioned above, use KVC and you get ample scope to store and retrieve state.

提交回复
热议问题