Search code examples
iphonecocoa-touchcore-animation

Does a CAKeyframeAnimation pick up the current state when a new CAKeyframeAnimation starts while another is running?


I wonder what would happen. i.e. I kick off a CAKeyframeAnimation, and while it runs I kick off another one on the same keyPath and object. I want it to pick up the current state, but unlike in the nice UIView CA wrapper methods, I don't see a "beginsFromCurrentState" property. So would it pick it up or not?


Solution

  • You want to query the layer for its presentation layer, which is its current interpolated state including any animations currently running.

    -

    Excerpt from the CALayer Class Reference:

     -(id)presentationLayer
    

    Returns a copy of the layer containing all properties as they were at the start of the current transaction, with any active animations applied.

    -

    The relationship of the Layer Tree (your data), the Presentation Tree (current interpolation values of your data), and the Render Tree are explained here in the CA programming guide.

    Core Animation Rendering Architecture