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.
10 Answers
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
-
21Dharmesh, thanks for the reply. This sucessfully hides the tab bar, but then table view does not fill the screen. It's just black where the tab bar should be. I guess there's another step to make it fit the screen?– RobertFeb 28, 2015 at 14:44
-
3
-
2
-
8But the tab bar would still take the touch, try tapping near any tab of invisible tab bar. @DharmeshKheni Jan 13, 2017 at 9:32
-
1Leaves a blank space. Better handle from storyboard option
Hide bottom bar on push
(checkbox).– TejasJul 27, 2022 at 3:51
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.
-
2that's what we should do. A lot better than other answers if you just want to hide it while you present the ViewController Jul 3, 2016 at 22:39
-
why is this not work in Swift 4?? I already tick the option,but it still appear when I go to that particular view controller– kenJan 18, 2018 at 11:02
-
This also hides the tab bar for any view controllers that get added to the stack after this. Is there a way to bring it back for those subsequent view controllers? Feb 2, 2018 at 20:40
-
@JustinVallely Please let me know if update works in the answer Feb 16, 2018 at 8:23
-
1Thanks, the accepted answer had a problem for me, when I go back to the view I was coming from, the Tabbar for that also was dissappeard! May 1, 2018 at 8:07
Before push set controller.hidesBottomBarWhenPushed = true
let objCreateEventVC = CreateEventVC()
objCreateEventVC.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(objCreateEventVC, animated: false)
No need to set tabBar's isHidden property.
Simply, Go to ViewController (in StoryBoard) -> Attribute inspector -> Under 'View Controller' section select 'Hide Bottom Bar on Push' checkbox. This works like a charm.
If you go the 'isHidden' way you need to do a lot of handling, i.e. to make it appear again when you go back and also to remove the bottom empty space after hiding tabBar.
-
3This should be the actual answer. This allowed me to set the constraints for my UI elements without any hassle. Dec 23, 2017 at 17:39
-
3
-
When you get back from this page, Tabbar freezes a little and comes back. What do you think is the reason? Jan 19, 2019 at 22:43
-
This doesn't work when the app comes from the background. Any idea?– Mac_PlayJul 26, 2021 at 14:49
Hide & Show Tab Bar With Animation
For those looking to hide/show the tab bar with animation.
Since iOS 13, the behavior of the UITabBar has changed for animations. You can no longer use CGAffineTransform
and instead you should animate its frame position.
See my full guide here: hide & show tab bar with animation

To hide the tab bar:
UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.7, options: .curveEaseOut) {
if let tabBarFrame = self.tabBarController?.tabBar.frame {
self.tabBarController?.tabBar.frame.origin.y = navigationController.view.frame.maxY + tabBarFrame.height
}
navigationController.view.layoutIfNeeded()
} completion: { _ in
self.tabBarController?.tabBar.isHidden = true
}
To show the tab bar:
UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.7, options: .curveEaseOut) {
if let tabBarFrame = self.tabBarController?.tabBar.frame {
self.tabBarController?.tabBar.frame.origin.y = navigationController.view.frame.maxY - tabBarFrame.height
}
navigationController.view.layoutIfNeeded()
}
Make sure to call layoutIfNeeded()
inside the UIView.animate
to trigger the changes with animation.
-
This is great, but how do you get the content above the tabBar to reclaim the empty space? May 30 at 5:14
-
Not sure if I fully understand your question, but depending on how you've set up your navigation stack, normally the content is behind the tab bar (not above) and therefore already occupies the empty space whether the tab bar is hidden or not. Is this what you meant?– sbiljeekJun 2 at 6:53
This is the way programmatically for Swift 4.0, 4.1, 4.2, 5.0 and later >:
tabBarController?.hidesBottomBarWhenPushed = true
or
hidesBottomBarWhenPushed = true
-
@NicoS. True. Where in the question/answer do you read anything about a tool bar?– J. DoeApr 9, 2019 at 6:28
-
From the documentation: A Boolean value indicating whether the toolbar at the bottom of the screen is hidden when the view controller is pushed on to a navigation controller.– Nico S.Apr 9, 2019 at 17:42
-
1
-
1the first one doesn't work, the second one should be added when performing a segue or before pushing the view controller. Sep 22, 2019 at 19:19
-
1thanks for: destinationVC.hidesBottomBarWhenPushed = true. For all other options the bottom bar was gone but a big black hole was there. Jun 17, 2020 at 14:34
You can also set it in extension (use Dharmesh Kheni answer)
extension UITabBar {
func tabsVisiblty(_ isVisiblty: Bool = true){
if isVisiblty {
self.isHidden = false
self.layer.zPosition = 0
} else {
self.isHidden = true
self.layer.zPosition = -1
}
}
Here is my code. it's just to hide its tabbar. (If no frames are well established there will be a black view at the bottom. )
var oldTabbarFr: CGRect = .zero
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
oldTabbarFr = self.tabBarController?.tabBar.frame ?? .zero
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.tabBarController?.tabBar.isHidden = true
self.tabBarController?.tabBar.frame = .zero
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.tabBarController?.tabBar.isHidden = false
self.tabBarController?.tabBar.frame = oldTabbarFr
}
To hide the navigationBar and the tabBar I use the next function:
var tabBarHeight : CGFloat!
func fullScreenAction(){
if navigationController?.isNavigationBarHidden ?? false {
//Show navigationBar
navigationController?.setNavigationBarHidden(false, animated: false)
//Show tabBar
tabBarController?.tabBar.isHidden = false
//Update the height of tabBar
if (!(tabBarController?.tabBar.frame.size.height.isEqual(to: 0))!) {
tabBarHeight = self.tabBarController?.tabBar.frame.size.height
}
tabBarController?.tabBar.frame.size.height = tabBarHeight
} else {
//Hide navigationBar
navigationController?.setNavigationBarHidden(true, animated: false)
//Hide tabBar
tabBarController?.tabBar.isHidden = true
//Update the height of tabBar
tabBarHeight = tabBarController?.tabBar.frame.size.height
tabBarController?.tabBar.frame.size.height = 0
}
}
When the screen orientation has changed the height of tabBar change too, so I use the next function to exit of fullscreen to resize the height:
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
if navigationController?.isNavigationBarHidden ?? false {
navigationController?.setNavigationBarHidden(false, animated: false)
tabBarController?.tabBar.isHidden = false
}
}
I hope it is useful for you.
vc.hidesBottomBarWhenPushed = true
should do the work. DO NOT manually show and hide the tabbar.