Hide tab bar in IOS swift app

后端 未结 8 2201
走了就别回头了
走了就别回头了 2020-12-22 19:19

I\'m trying to figure out how to hide the tab bar in my iOS swift app. I don\'t care about any fancy animations or anything. Just something I can put in the ViewDidLoad() fu

相关标签:
8条回答
  • 2020-12-22 19:47

    This is the way programmatically for Swift 4.0, 4.1, 4.2, 5.0 and later >:

    tabBarController?.hidesBottomBarWhenPushed = true
    

    or

    hidesBottomBarWhenPushed = true
    
    0 讨论(0)
  • 2020-12-22 19:49

    The accepted answer works, but the transition to other view has a choppy animation (The tab Bar animation)

    Also wanted to add although Kalpesh's solution worked perfectly for me, I found out that every view controller has an attribute for hidesBottomBarWhenPushed (check out storyboard.) If you wish to hide tab bar, you should put a tick on that. And it would work great.

    Update: Im not sure if this is a known thing, but here's what apple documentation page says:

    A view controller added as a child of a navigation controller can display an optional toolbar at the bottom of the screen. The value of this property on the topmost view controller determines whether the toolbar is visible. If the value of this property is true, the toolbar is hidden. If the value of this property is false, the bar is visible.

    I think this means that you have to set the basic value of hidesBottomBarWhenPushed at the topmost view controller (the first one on the navigation stack.) Once you have set that to true, you can change to false or true for the other viewcontrollers on the stack. But, if your topmost view controller's hidesBottomBarWhenPushed value is false, it will not show a tab bar for other controllers on the navigation stack.

    0 讨论(0)
提交回复
热议问题