Moving CALayer and content transition animation

  • Hello,

      I have a delegate-drawn CALayer which uses a kCATransitionFade content
    transition animation set in -actionForLayer:forKey: of its delegate.

    This works fine if the layer is not moving. When the content changes, the new
    content simply fades in, the old one fades out.

    However, when the layer is moving at the time its content changes, the old
    content fades out but it remains stationary where the layer was when the
    transition started. It no longer moves along with the layer position. The new
    content fades in, moving with the layer.

    Is this to be expected? If so, what is the proper way of handling this? Surely
    there must be something basic I'm missing again.

    Thanks for any pointers!

    Regards
    Markus
    --
    __________________________________________
    Markus Spoettl
  • On 6/7/12 2:14 AM, Markus Spoettl wrote:
    > Hello,
    >
    > I have a delegate-drawn CALayer which uses a kCATransitionFade content
    > transition animation set in -actionForLayer:forKey: of its delegate.
    >
    > This works fine if the layer is not moving. When the content changes,
    > the new content simply fades in, the old one fades out.
    >
    > However, when the layer is moving at the time its content changes, the
    > old content fades out but it remains stationary where the layer was when
    > the transition started. It no longer moves along with the layer
    > position. The new content fades in, moving with the layer.
    >
    > Is this to be expected? If so, what is the proper way of handling this?
    > Surely there must be something basic I'm missing again.
    >
    > Thanks for any pointers!

    I haven't had a chance to test it myself, but what if you set the
    transition animation on the layer's -presentationLayer instead of on the
    layer directly?

    --
    Conrad Shultz

    Synthetiq Solutions
    www.synthetiqsolutions.com
  • On 6/7/12 9:39 PM, Conrad Shultz wrote:
    >> Is this to be expected? If so, what is the proper way of handling this?
    >> Surely there must be something basic I'm missing again.
    >>
    >> Thanks for any pointers!
    >
    > I haven't had a chance to test it myself, but what if you set the
    > transition animation on the layer's -presentationLayer instead of on the
    > layer directly?

    Isn't -presentationLayer is read-only? Even if it weren't, I'm not sure how that
    would work. The layer re-positioning is done in a non-animated fashion (within
    CATransation -begin, -disableActions:YES, -commit) and can happen a couple of
    times during the content animation. It's basically a layer that's dragged along
    with the mouse cursor.

    Regards
    Markus
    --
    __________________________________________
    Markus Spoettl
  • On 6/7/12 1:12 PM, Markus Spoettl wrote:
    > On 6/7/12 9:39 PM, Conrad Shultz wrote:
    >>> Is this to be expected? If so, what is the proper way of handling this?
    >>> Surely there must be something basic I'm missing again.
    >>>
    >>> Thanks for any pointers!
    >>
    >> I haven't had a chance to test it myself, but what if you set the
    >> transition animation on the layer's -presentationLayer instead of on the
    >> layer directly?
    >
    > Isn't -presentationLayer is read-only? Even if it weren't, I'm not sure
    > how that would work. The layer re-positioning is done in a non-animated
    > fashion (within CATransation -begin, -disableActions:YES, -commit) and
    > can happen a couple of times during the content animation. It's
    > basically a layer that's dragged along with the mouse cursor.

    -presentationLayer is generated by Core Animation but you can
    -addAnimation: to it seemingly without ill effect; I was once told that
    this is an approach akin to using the
    UIViewAnimationOptionBeginFromCurrentState on iOS, but as I said this is
    somewhat speculative and from second-hand experience.

    In any event, it sounds like I misunderstood your problem.  I thought
    the layer was moving because you had added an animation to it, which
    made me think the problem might be the divergence between the layer and
    its presentationLayer.  This doesn't sound like what you are actually
    doing, so my idea (valid or not) doesn't really apply here anyway.

    --
    Conrad Shultz

    Synthetiq Solutions
    www.synthetiqsolutions.com
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today