Reputation: 2951
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.
Upvotes: 20
Views: 20090
Reputation: 53171
There's no constant containing this value. However, using the following UINavigationControllerDelegate
methods:
- (void) navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
startTime = [[NSDate date] retain];
}
- (void) navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
NSLog(@"Duration %f", [[NSDate date] timeIntervalSinceDate: startTime]);
}
... I can see that the duration is approx 0.35 seconds
Interestingly, different parts of the views take different times to transition into place. See this great blog post for more details:
http://www.iclarified.com/12396/a-closer-look-at-iphone-transition-animations
Upvotes: 23
Reputation: 6204
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.
Upvotes: 27