Hide TabBar in iOS 6

末鹿安然 提交于 2019-12-06 00:45:58

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!