Search code examples
cocoa-touchanimationcore-animationcalayercakeyframeanimation

Implicit animation not working


As I'm trying to override implicit animation on the position property, the layer quickly flashes to the destination position and then starts my explicit animation:

CAKeyframeAnimation* animation = [CAKeyframeAnimation animation];
animation.path = path; // some CGPath
animation.duration = 1.0;

[newTopLayer setPosition:CGPointMake(x, y)]; // Setting final values for stickness
[newTopLayer addAnimation:animation forKey:@"position"];

It seem that the position key doesn't get overriden. Why? I tried it with CATransaction, but still no luck.

Update
Further investigations had shown, that the newTopLayer is not implicitly animated anyway. For info: it's backed by an UIView.


Solution

  • OK, it's that simple: if a CALayer is backed by UIView, then all implicit animations are disabled. If you need an implicit animation, make a sub-layer to a UIView's layer.