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.
Almost all animations in the iPhone are 0.3 seconds.
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.
open the simulator and switch to slow animation, i found the push animation duration is 0.35f second
The duration between viewWillAppear
and viewDidAppear
is 0.35s on iOS 6 and before. After iOS 7 it's 0.505s.
精彩评论