Add CALayer as a sublayer and then animate
here's what i want to do: add a CALayer as a sublayer for the antoher layer, and then animate it immediately. The layer is added at a position outside of the current view and should "fly" into the view. This all happens in the UIViewController.
This is what my code looks like:
mysublayer.position = CGPointMake(-160.0, -250.0);
[self.view.layer addSublayer:mysublayer];
[CATransaction begin]; // outer transaction
[CATransaction setValue:[NSNumber numberWithFloat:2.0f]
forKey:kCATransactionAnimationDuration];
mysublayer.position = CGPointMake(160.0, 250.0);
mysublayer.opacity = 1.0;
[CATransaction commit];
It happens that a sublayer immediately appears in a new position (160 250) without animation. I think I am doing something fundamental, and the moment I try to animate the layer, it is not added to the parent layer, right?
So, to wrap it, how do I animate the new sublevel after adding it to the parent layer?
Thanks and kind, Hans
+1
source to share