How long is the animation of the transition between views on a UINavigationController?

morais picture morais · Sep 30, 2011 · Viewed 15.1k times · Source

Ideally, there would be some kind of constant containing this value.

I'm implementing code that has it's own transition animations, and I'd like those to have the same length as the platform transition animations.

Answer

Tomasz Bąk picture Tomasz Bąk · Feb 27, 2015

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.