UINavigationController UINavigationControllerHideShowBarDuration
extern const CGFloat UINavigationControllerHideShowBarDuration
Constants
UINavigationControllerHideShowBarDuration
This variable specifies the duration when animating the navigation bar. Note that this is a constant value, so it cannot be set.
UINavigationController UINavigationControllerHideShowBarDuration example.
[self.navigationController setNavigationBarHidden:YES animated:YES];
[UIView transitionWithView:self.view
duration:UINavigationControllerHideShowBarDuration
options:UIViewAnimationOptionCurveLinear
animations:^
{
/* Put other animation code here ;) */
}
completion:^(BOOL finished)
{
}];
[UIView transitionWithView:self.view
duration:UINavigationControllerHideShowBarDuration
options:UIViewAnimationOptionCurveLinear
animations:^
{
/* Put other animation code here ;) */
}
completion:^(BOOL finished)
{
}];
Example of [UINavigationController UINavigationControllerHideShowBarDuration].
- (void)pushViewControllerAfterAnimation:(UIViewController *)viewController animated:(BOOL)animated {
[UIView transitionWithView:viewController.view
duration:UINavigationControllerHideShowBarDuration
options:UIViewAnimationCurveEaseOut
animations:^{
[self.navigationController setNavigationBarHidden:NO];
}
completion:^(BOOL finished){
NSLog(@"animation finished");
[self pushViewController:viewController animated:animated];
}];
}
- (void)popViewControllerAfterAnimationAnimated:(BOOL)animated {
[UIView transitionWithView:self.visibleViewController.view
duration:UINavigationControllerHideShowBarDuration
options:UIViewAnimationCurveEaseOut
animations:^{
[self.navigationController setNavigationBarHidden:YES];
}
completion:^(BOOL finished){
NSLog(@"animation finished");
[self popViewControllerAnimated:animated];
}];
}
[UIView transitionWithView:viewController.view
duration:UINavigationControllerHideShowBarDuration
options:UIViewAnimationCurveEaseOut
animations:^{
[self.navigationController setNavigationBarHidden:NO];
}
completion:^(BOOL finished){
NSLog(@"animation finished");
[self pushViewController:viewController animated:animated];
}];
}
- (void)popViewControllerAfterAnimationAnimated:(BOOL)animated {
[UIView transitionWithView:self.visibleViewController.view
duration:UINavigationControllerHideShowBarDuration
options:UIViewAnimationCurveEaseOut
animations:^{
[self.navigationController setNavigationBarHidden:YES];
}
completion:^(BOOL finished){
NSLog(@"animation finished");
[self popViewControllerAnimated:animated];
}];
}
UINavigationController UINavigationControllerHideShowBarDuration example.
Only improvement would be setting anim duration to be consistent with other navigation controller animations:
[UIView setAnimationDuration:UINavigationControllerHideShowBarDuration];
[UIView setAnimationDuration:UINavigationControllerHideShowBarDuration];