I am using this code to hide the TabBar:
self.tabBarController.tabBar.hidden=YES;
I am hiding tabBarController in my project.but it showing black bar in bottom of the view in Ios7.When i go back to the same view it is looking good.any help will be appreciated.
If you don't want that behavior, you should set hidesBottomBarWhenPushed to true where applicable. This will hide the tab bar along with any toolbars you had showing, but only when a view controller is pushed onto the navigation stack. This allows you to show the tab bar at first, then hide it when you need more room.
You can do this in storyboard now: Select the UIViewController in your storyboard. Select the checkbox Hide Bottom Bar on Push.
Answer: Use self. tabBarController?. tabBar. hidden instead of hidesBottomBarWhenPushed in each view controller to manage whether the view controller should show a tab bar or not.
A TabBar is a control that is used to display and configure one or more bar button items in a tab bar for selecting between different subtasks, views, or modes in the iOS application. The TabBar is used in association with the TabBarController to present the list of tabs in the application.
NOTE: It is solution for iOS6 and 7 only.
In iOS 7 to extend clickable area and hide black bar on place of hidden UITabBar you should enable 'Extend Edges - Under Opaque Bars' option for you UIViewController.
Or you can set this property programmatically:
[self setExtendedLayoutIncludesOpaqueBars:YES]
Here is example of code that hide or move TabBar for iOS 6/7:
UITabBarController *bar = [self tabBarController]; if ([self respondsToSelector:@selector(setExtendedLayoutIncludesOpaqueBars:)]) { //iOS 7 - hide by property NSLog(@"iOS 7"); [self setExtendedLayoutIncludesOpaqueBars:YES]; bar.tabBar.hidden = YES; } else { //iOS 6 - move TabBar off screen NSLog(@"iOS 6"); CGRect screenRect = [[UIScreen mainScreen] bounds]; float height = screenRect.size.height; [self moveTabBarToPosition:height]; } //Moving the tab bar and its subviews offscreen so that top is at position y -(void)moveTabBarToPosition:(int)y { self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, y, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height); for(UIView *view in self.tabBarController.view.subviews) { if ([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, y, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, y)]; view.backgroundColor = [UIColor blackColor]; } } }
Function to moving the Tab Bar offscreen got from this post.
Next code works for me
- (void)showTabBar { [self.tabBar setTranslucent:NO]; [self.tabBar setHidden:NO]; } - (void)hideTabBar { [self.tabBar setTranslucent:YES]; [self.tabBar setHidden:YES]; }
Try this:
- (BOOL)hidesBottomBarWhenPushed {
return YES;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With