Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanjrogers/671924 to your computer and use it in GitHub Desktop.
Save alanjrogers/671924 to your computer and use it in GitHub Desktop.
Allow left or right transition for UINavigationController
- (void)loadViewController:(UIViewController*)viewController withTransition:(AJRNavigationControllerTransition)transition
{
// This currently only works for a landscape only App.
// Needs to check orientation as nav controller view isn't rotated.
NSString* subtype = kCATransitionFromBottom;
switch (transition)
{
case AJRNavigationControllerTransition_FromLeft:
{
subtype = ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft) ? kCATransitionFromTop : kCATransitionFromBottom;
break;
}
case AJRNavigationControllerTransition_FromRight:
{
subtype = ([self interfaceOrientation] == UIInterfaceOrientationLandscapeRight) ? kCATransitionFromTop : kCATransitionFromBottom;
break;
}
default:
break;
}
CATransition *animation = [CATransition animation];
[animation setDuration:0.25];
[animation setType:kCATransitionPush];
[animation setSubtype:subtype];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self.navigationController.view layer] addAnimation:animation forKey:@"SwitchToView1"];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
[UIView setAnimationBeginsFromCurrentState:YES];
[self.navigationController pushViewController:viewController animated:NO];
[UIView commitAnimations];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment