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() function.
If you don't want that behavior, you should set hidesBottomBarWhenPushed to true where applicable. This will hide the tab bar along with any toolbars you had showing, but only when a view controller is pushed onto the navigation stack. This allows you to show the tab bar at first, then hide it when you need more room.
Right click on the tab you want to hide. Select Hide.
Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.
You can simply use this in your ViewDidLoad()
method.
self.tabBarController?.tabBar.hidden = true
For Swift 3.0, 4.0, 5.0:
self.tabBarController?.tabBar.isHidden = true
Or you can change z position of tab bar this way:
self.tabBarController?.tabBar.layer.zPosition = -1
and if you want to show it again then:
self.tabBarController?.tabBar.layer.zPosition = 0
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With