Search code examples
iphonecocoa-touchcore-animation

Does the -presentationLayer tell me the in-flight values of an view while it is beeing animated?


The doc says:

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.

And somewhere else Apple said, that the presentation layer contains the values like they are currently displayed to the user. So when I ask for this layer, why would it tell me how the thing looked before starting to animate? That doesn't make sense. Is that an documentation error?


Solution

  • The documentation is correct. What they are saying is that the presentationLayer is based on the initial state of the layer, but it has the appropriate animations applied. As the animations progress, the appropriate values of the presentationLayer change to match the currently displayed state of the layer.

    For example, if the layer started at origin coordinate (100,0) and you applied an animation to move it to (200,0), halfway through the animation the presentationLayer's origin coordinate would be (150,0). If the same animation was applied to a layer starting at coordinate (0,0), then halfway through the animation the presentationLayer would have an origin of (100,0).