Why CABasicAnimation will send the layer's view to back and front?
Posted
by
ohho
on Stack Overflow
See other posts from Stack Overflow
or by ohho
Published on 2011-01-08T02:15:12Z
Indexed on
2011/01/13
3:53 UTC
Read the original article
Hit count: 435
There are two UIViews of similar size. UIView one (A) is originally on top of UIView two (B). When I try to perform a CABasicAnimation transform.rotation.y
on A's layer:
CABasicAnimation *rotateAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
CGFloat startValue = 0.0;
CGFloat endValue = M_PI;
rotateAnimation.fromValue = [NSNumber numberWithDouble:startValue];
rotateAnimation.toValue = [NSNumber numberWithDouble:endValue];
rotateAnimation.duration = 5.0;
[CATransaction begin];
[imageA.layer addAnimation:rotateAnimation forKey:@"rotate"];
[CATransaction commit];
During the animation, the animating layer's UIView (A) will be:
- sent back (A is suddenly behind B)
- rotating ... passed second half of the animation
- sent front (A is now on top of B again)
Is there a way to keep A on top of B for the whole animation period? Thanks!
UPDATE: project source is attached: FlipLayer.zip
© Stack Overflow or respective owner