在iOS 6中隐藏TabBar

时间:2013-12-04 06:30:58

标签: ios iphone ios6 ios7 uitabbar

我想在iOS 6中隐藏我的TabBar,当我编写下面给出的代码时,它在iOS 7中有效但在iOS 6中显示黑线

self.tabBarController.tabBar.hidden = YES;

以下是iOS 6

的快照

2 个答案:

答案 0 :(得分:3)

尝试使用以下代码可能会对您有所帮助......

- (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)];
            }
        }
    }
}

答案 1 :(得分:0)

当您按下视图控制器时,只需使用  yourViewController.hidesBottomBarWhenPushed = YES;  [yourTabbarNavigationController pushViewController:helpViewController animated:YES];

这将删除黑色transculent图层,但如果您使用自定义tabbar,则还必须明确隐藏这些视图。