سؤال

When we push any viewController, then the next controller comes from right to left. But when we present any view controller then the next controller comes from bottom to top. I want when we present any controller it comes from right to left same as that comes in pushing. I donot want to use modalViewController.

هل كانت مفيدة؟

المحلول

While presenting controller use this code:

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];

and when you dismiss, use this code:

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];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top