Hide tab bar in IOS swift app
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
In UIKit apps, the most common reason to hide the tab bar is to give a detail screen more room or remove tab switching during a focused flow. The correct approach depends on how the next screen is shown. If the screen is pushed inside a navigation controller, hidesBottomBarWhenPushed is usually the right tool.
Use hidesBottomBarWhenPushed for Pushed Screens
When a tab contains a navigation controller, a pushed detail view can ask UIKit to hide the tab bar automatically.
This is the cleanest pattern because UIKit manages the tab bar visibility during the push and pop transitions. When the user pops back, the tab bar returns automatically.
Set the Property Before the Push
The timing matters. Set hidesBottomBarWhenPushed before you call pushViewController. If you set it later in viewDidLoad or viewWillAppear, the transition may already be decided.
This pattern is correct:
This is not reliable:
By that point, the controller may already have been pushed.
Understand the Container Hierarchy
The property only affects the push behavior when the tab bar controller owns a navigation controller, and that navigation controller pushes the next screen. A common structure is:
UITabBarController- one
UINavigationControllerper tab - content view controllers inside each navigation stack
If your app presents a screen modally instead of pushing it, hidesBottomBarWhenPushed does not control that presentation. In modal flows, the tab bar usually remains behind the presented controller because the modal covers the whole screen.
Hiding the Tab Bar Manually
Sometimes developers try to hide the tab bar by changing tabBar.isHidden directly:
This can work for special cases, but it is more fragile than hidesBottomBarWhenPushed. Manual hiding can create layout glitches, broken safe-area insets, or inconsistent animations during navigation transitions.
If you choose manual control, you should also restore visibility at the right time:
That approach is usually a fallback, not the first choice.
Full Example With a Tab and Navigation Setup
Here is a minimal app setup where the first tab pushes a details screen that hides the tab bar:
This pattern matches how many production tab-based UIKit apps are structured.
When Hiding the Tab Bar Makes Sense
Use a hidden tab bar when the user should focus on one screen at a time, such as:
- item details
- full-screen media
- onboarding steps inside a tab
- edit flows where tab switching would be distracting
If the destination is still part of regular tab navigation, hiding the tab bar may make navigation less clear rather than better.
Common Pitfalls
The most common mistake is setting hidesBottomBarWhenPushed too late, after the push is already happening. Another is trying to use it for modal presentation, where it does not control the same behavior. Developers also hide tabBar.isHidden manually and then forget to restore it, which leaves later screens in a broken state. Layout issues can appear if the tab bar is hidden without considering safe-area changes. In most standard navigation flows, the simplest fix is to push from a navigation controller and set hidesBottomBarWhenPushed before the push.
Summary
- Use
hidesBottomBarWhenPushedfor screens pushed inside a navigation stack. - Set the property before calling
pushViewController. - Prefer automatic UIKit behavior over manual
tabBar.isHiddentoggling. - Manual hiding is possible, but it requires careful restore logic and layout testing.
- The common container structure is a tab bar controller containing navigation controllers.
- Hide the tab bar only when it improves focus and navigation clarity.
Related reading
- Hide the cursor of a UITextField
- Hiding the master view controller with UISplitViewController in iOS8
- ''Higher minimum deployment target'' error when installing Firebase Crash Reports Pods for iOS
- Hooking up UIButton to closure? Swift, target-action
- Horizontal ListView in Android?
- HorizontalScrollView within ScrollView Touch Handling
- How big should a UIBarButtonItem image be?
- How can a divider line be added in an Android RecyclerView?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.