Pushcontroller就像呈现视图控制器的过渡一样

时间:2014-02-03 07:00:29

标签: ios iphone ios4 uiviewcontroller

当我们推送任何viewController时,下一个控制器从右到左。但是当我们呈现任何视图控制器时,下一个控制器将自下而上。我希望当我们呈现任何控制器时,它从右到左,与推进时相同。我不想使用modalViewController。

1 个答案:

答案 0 :(得分:3)

在呈现控制器时使用此代码:

CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];

[self presentModalViewController:viewController animated:NO];

当你解雇时,请使用以下代码:

CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view.window.layer addAnimation:transition forKey:nil];

[self dismissModalViewControllerAnimated:NO];