我有两个视图,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];
任何帮助将不胜感激。
答案 0 :(得分:3)
你看过这个方法......
[UIView transitionFromView:jumpBarContainerPortrait
toView:jumpBarContainerLandscape
duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve
completion:^(BOOL finished) {}];
或者将fromView / toView翻转回来。
答案 1 :(得分: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];