How to Hide Tab Bar Controller?

后端 未结 10 1650
猫巷女王i
猫巷女王i 2020-12-05 00:43

How to Hide Tab Bar Controller ? I want to hide the Tab Bar controller with double tap on UIImageView.

相关标签:
10条回答
  • 2020-12-05 01:18

    Use the code below to hide/show tab bar controller in animated style.
    hiddenTabBar is a BOOL variable.

    - (void) hidetabbar {
    
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.0];
    
        for(UIView *view in objtabbar.view.subviews)
        {
    
            if([view isKindOfClass:[UITabBar class]])
            {
    
                if (hiddenTabBar) {
                    [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
                } else {
                    [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
                }
            } else {
                if (hiddenTabBar) {
                    [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
                } else {
                    [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
                }
    
            }
        }
    
        [UIView commitAnimations];
    
        hiddenTabBar = !hiddenTabBar;
    }
    
    0 讨论(0)
  • 2020-12-05 01:21

    Try this when you push the view to the new view:

    self.tabbarconroller.tabbar.hidden = YES;
    
    0 讨论(0)
  • 2020-12-05 01:24

    If using Storyboards you can simply uncheck a checkbox in your ViewController's Attribute Inspector. It's called "Hide Bottom Bar on Push". Very convenient indeed, and no need to handle the showing of the tabBar again after navigating back from your tabBar-less viewController. I don't know in which XCode-version this was introduced, but it's there for XCode 6 + .

    0 讨论(0)
  • 2020-12-05 01:27

    Swift 2.1:

    self.tabBarController!.tabBar.hidden = true
    
    0 讨论(0)
提交回复
热议问题