0

我有两个视图, jumpBarPortrait 和 jumpBarLandscape 我想在两者之间制作动画,所以换句话说,我希望肖像淡入,而风景淡出......到目前为止,我可以淡入一个,但我不知道如何让另一个淡出...

这是我目前的代码..

[CATransaction begin];
CATransition *animation = [CATransition animation];
animation.type = kCATransitionFade;
animation.duration = animationSpeed;

[self.view insertSubview:jumpBarContainerPortrait belowSubview:actionTabBar];

[[jumpBarContainerPortrait layer] addAnimation:animation forKey:@"Fade"];
[CATransaction commit];

任何帮助将不胜感激。

4

2 回答 2

3

你看过这个方法吗...

        [UIView transitionFromView:jumpBarContainerPortrait
                            toView:jumpBarContainerLandscape
                          duration:0.5
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        completion:^(BOOL finished) {}];

或翻转 fromView/toView 以转换回来。

于 2012-06-22T04:01:22.177 回答
0

您插入视图以淡入但不删除视图淡出,试试这个:

[CATransaction begin];
CATransition *animation = [CATransition animation];
animation.type = kCATransitionFade;
animation.duration = animationSpeed;

[self.view insertSubview:jumpBarContainerPortrait belowSubview:actionTabBar];
[[jumpBarContainerPortrait layer] addAnimation:animation forKey:@"Fade"];

[fadeOutView removeFromSuperview];
[[fadeOutView layer] addAnimation:animation forKey:@"Fade"];

[CATransaction commit];
于 2012-06-22T02:54:15.223 回答