问题
I want to Hide my TabBar in iOS 6
, when i wrote the code which is given below it works in iOS 7
but it shows black line in iOS 6
self.tabBarController.tabBar.hidden = YES;
Here is snapshot for iOS 6
回答1:
Try with below code May be this will help you...
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if([UIScreen mainScreen].bounds.size.height==568)
{
[view setFrame:CGRectMake(view.frame.origin.x, 568 +20, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, 480+20, view.frame.size.width, view.frame.size.height)];
}
}
else
{
if([UIScreen mainScreen].bounds.size.height==568)
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 568)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
}
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if([UIScreen mainScreen].bounds.size.height==568)
{
[view setFrame:CGRectMake(view.frame.origin.x, 519, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
}
else
{
if([UIScreen mainScreen].bounds.size.height==568)
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 519)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
}
}
回答2:
When you are pushing view controller just use yourViewController.hidesBottomBarWhenPushed = YES; [yourTabbarNavigationController pushViewController:helpViewController animated:YES];
This will remove black transculent layer,but if u are using custom tabbar then you will have to explicitly hide those view also.
来源:https://stackoverflow.com/questions/20368589/hide-tabbar-in-ios-6