6

I am pushing my view controller with the following statement :

[[self navigationController] pushViewController:self.customViewController animatedWithTransition:UIViewAnimationTransitionFlipFromLeft];

Now when I am pressing the back button I want to animate it with the uiviewanimationtransitionflipfromright .

like

[self.navigationController popViewControllerAnimatedWithTransition:UIViewAnimationTransitionFlipFromLeft];

How Can I do so ?

Thanks

harshalb
  • 5,952
  • 13
  • 55
  • 91

3 Answers3

5

This helps you to animating the view in back button.

[UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
Shawn Chin
  • 79,172
  • 18
  • 156
  • 188
Swift-Master
  • 530
  • 4
  • 13
2

For Push:

MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [self.navigationController pushViewController:nextView animated:NO];
                         [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
                     }];

For Pop:

[UIView animateWithDuration:0.75
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
                     }];
[self.navigationController popViewControllerAnimated:NO];

https://stackoverflow.com/a/5889757/1915820

Community
  • 1
  • 1
rilar
  • 3,139
  • 4
  • 28
  • 42
1

See here for doing custom back anim:

Prevent the animation when clicking "Back" button in a navigation bar?

Community
  • 1
  • 1
Adam
  • 32,582
  • 16
  • 122
  • 149