UINavigationController setNavigationBarHidden
- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated
Parameters
hidden
Specify YES to hide the navigation bar or NO to show it.
animated
Specify YES if you want to animate the change in visibility or NO if you want the navigation bar to appear immediately.
Discussion of [UINavigationController setNavigationBarHidden]
For animated transitions, the duration of the animation is specified by the value in the UINavigationControllerHideShowBarDuration constant.
UINavigationController setNavigationBarHidden example.
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewWillDisappear:animated];
}
Example of [UINavigationController setNavigationBarHidden].
- (void) viewWillDisappear:(BOOL)animated
{
if (self.navigationController.topViewController != self)
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
[super viewWillDisappear:animated];
}
{
if (self.navigationController.topViewController != self)
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
[super viewWillDisappear:animated];
}
UINavigationController setNavigationBarHidden example.
For the UINavigationController:
[UINavigationBar beginAnimations:@"NavBarFade" context:nil];
self.navigationController.navigationBar.alpha = 1;
[self.navigationController setNavigationBarHidden:YES animated:NO]; //Animated must be NO!
[UINavigationBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UINavigationBar setAnimationDuration:1.5];
self.navigationController.navigationBar.alpha = 0;
[UINavigationBar commitAnimations];
For the UITabBarController:
[UITabBar beginAnimations:@"TabBarFade" context:nil];
self.tabBarController.tabBar.alpha = 1;
[self.tabBarController.tabBar setHidden:YES];
[UITabBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UITabBar setAnimationDuration:1.5];
self.tabBarController.navigationBar.alpha = 0;
[UITabBar commitAnimations];
[UINavigationBar beginAnimations:@"NavBarFade" context:nil];
self.navigationController.navigationBar.alpha = 1;
[self.navigationController setNavigationBarHidden:YES animated:NO]; //Animated must be NO!
[UINavigationBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UINavigationBar setAnimationDuration:1.5];
self.navigationController.navigationBar.alpha = 0;
[UINavigationBar commitAnimations];
For the UITabBarController:
[UITabBar beginAnimations:@"TabBarFade" context:nil];
self.tabBarController.tabBar.alpha = 1;
[self.tabBarController.tabBar setHidden:YES];
[UITabBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UITabBar setAnimationDuration:1.5];
self.tabBarController.navigationBar.alpha = 0;
[UITabBar commitAnimations];