如何在没有任何透明度/淡入淡出效果的情况下执行kCATransitionPush动画

Ant*_*ony 7 iphone core-animation objective-c uiviewcontroller uinavigationcontroller

可能重复:
iPhone CATransition为任何动画的开始和结束添加淡入淡出?

我正在尝试复制[UIViewController presentModalViewController:animated:]执行的"从底部向上滑动"动画,但不调用它,因为我不想要模态视图.

下面的核心动画代码非常接近但似乎在改变视图的透明度值.在动画开始时,您可以部分地透过视图向上滑动.在动画的中间/结尾,我们滑过的视图是完全透明的,所以我们可以看到它背后.在这个动画中,我希望两者都保持完全不透明.

有关如何停止透​​明度的任何想法在此代码中更改或以其他方式获得我正在寻找的"向上滑动动画"而无需模态视图?

UIViewController *nextViewController = [[UIViewController alloc] autorelease];
nextViewController.view.backgroundColor = [UIColor redColor];  
CATransition *animation = [CATransition animation];
animation.duration = 3.5;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromTop;  
[self.navigationController pushViewController:nextViewController animated:NO];
[self.navigationController.view.layer addAnimation:animation forKey:nil];
Run Code Online (Sandbox Code Playgroud)

Jas*_*man 0

除了 CATransition,您还可以尝试使用 CABasicAnimation,将位置从屏幕顶部动画到所需的位置。