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
  • 6,012
  • 13
  • 56
  • 92

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
  • 84,080
  • 19
  • 162
  • 191
Vikas Pandey
  • 550
  • 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
0xRLA
  • 3,279
  • 4
  • 30
  • 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,900
  • 16
  • 126
  • 153