Is it possible to show pushViewController
animation look like presentModalViewController
but that has background functionality of pushViewController
?

- 4,241
- 10
- 40
- 81

- 1,061
- 6
- 16
- 31
5 Answers
If you want to a fade animation, this approach works.
CATransition* transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:gridController animated:NO];

- 1,581
- 4
- 17
- 45

- 7,581
- 5
- 47
- 81
-
1Works like a champ! Nice transition. Thanks! – David H Apr 13 '12 at 01:15
-
Works beautifully! Thanks a lot! – Amit Feb 14 '13 at 16:50
-
This is the best approach I've found so far. Other methods were causing errors in the frames of the view, or in the navigation controller bar itself. This animation is working awesomely! – The dude Jan 24 '14 at 09:01
Try this :
UIViewController *yourViewController = [[UIViewController alloc]init];
[UIView beginAnimations: @"Showinfo"context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController: yourViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

- 46,283
- 15
- 111
- 140

- 1,885
- 1
- 16
- 23
-
1
-
6Is this code doing as its says? As its not for Making animation like Present View Controller. – Dilip Manek Mar 23 '15 at 12:02
For display PushViewConttroler animation as Present below code is working,
For Push
ViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
CATransition* transition = [CATransition animation];
transition.duration = 0.4f;
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[self.navigationController pushViewController:VC animated:NO];
And for POP
CATransition* transition = [CATransition animation];
transition.duration = 0.4f;
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[self.navigationController popViewControllerAnimated:NO];
There is 1 issue though, that its display light black background when its going up/down,
Working on that, As soon as its done post new code here.

- 15,269
- 2
- 94
- 81

- 9,095
- 5
- 44
- 56
-
-
@Dilip : Have you solved that display light black background when its going up/down issue?? If you have solved, then plz update your answer.. – Meet Doshi Jan 11 '16 at 05:12
-
2@MeetDoshi, Sorry not able to solve this issue, but i have overcome this issue by setting colour of app window to my app theme, so that way its less noticeable. – Dilip Manek Jan 11 '16 at 05:29
-
As I have a monochromatic background, I got rid of the light black background with a little (dirty) for loop. Here you go in your origin VC: `for (UIView *view in self.view.subviews) { view.backgroundColor = someColor }` – pommefrite May 30 '16 at 08:06
For All Trying in Xamarin (C#) equivalent Code From Answer by @hardik Thakkar above, Has the issue of Black backgound during animation, rest all good.
For POP
CATransition transition = CATransition.CreateAnimation();
transition.Duration = 0.4;
transition.Type = CAAnimation.TransitionReveal;
transition.Subtype = CAAnimation.TransitionFromTop;
this.NavigationController.View.Layer.AddAnimation(transition, nameof(CATransition));
For Push
CATransition transition = CATransition.CreateAnimation();
transition.Duration = 0.4;
transition.Type = CAAnimation.TransitionReveal;
transition.Subtype = CAAnimation.TransitionFromBottom;
this.NavigationController.View.Layer.AddAnimation(transition, nameof(CATransition));

- 230
- 3
- 9
You should consider doing something like:
ViewController *myVC = [[ViewController alloc] initWithFrame:OFF_SCREEN];
[navigationController pushViewController:myVC animated:NO];
where OFF_SCREEN is some CGRect below the screen, like (0, 481, 320, 480). Then use an animation block to adjust the viewcontroller's view's frame.origin to be (0, 0). You would probably want to do the animate block in viewDidLoad or viewDidAppear.

- 5,207
- 5
- 38
- 54