8
votes

When I push or pop a UIViewController, how long does the animation takes to complete the slide animation. I have a view on the main window, which I need to slide in sync when a ViewController is pushed or popped.

Does anyone has any idea on the type and duration of animation that takes place when I push or pop a view.

Thanks in advance.

4
It would be great if there were a programmatic way of retrieving this value... - Ricardo Sanchez-Saez

4 Answers

18
votes

Almost all animations in the iPhone are 0.3 seconds.

6
votes

In iOS 7 and later you can have exact value by setting the UINavigationController delegate and using the method:

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated {
    NSTimeInterval duration = [viewController.transitionCoordinator transitionDuration];
}  

This is future proof method if the defult duration will ever change. At the moment it's value is 0.35 second.

4
votes

open the simulator and switch to slow animation, i found the push animation duration is 0.35f second

2
votes

The duration between viewWillAppear and viewDidAppear is 0.35s on iOS 6 and before. After iOS 7 it's 0.505s.