iOS
Swift
tab bar
app development
user interface

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.

Browse interview questions

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.

swift
1import UIKit
2
3final class HomeViewController: UIViewController {
4    override func viewDidLoad() {
5        super.viewDidLoad()
6        view.backgroundColor = .systemBackground
7    }
8
9    @objc func showDetails() {
10        let details = DetailsViewController()
11        details.hidesBottomBarWhenPushed = true
12        navigationController?.pushViewController(details, animated: true)
13    }
14}
15
16final class DetailsViewController: UIViewController {
17    override func viewDidLoad() {
18        super.viewDidLoad()
19        view.backgroundColor = .white
20    }
21}

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:

swift
let controller = DetailsViewController()
controller.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(controller, animated: true)

This is not reliable:

swift
1override func viewDidLoad() {
2    super.viewDidLoad()
3    hidesBottomBarWhenPushed = true
4}

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:

  1. UITabBarController
  2. one UINavigationController per tab
  3. 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:

swift
tabBarController?.tabBar.isHidden = true

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:

swift
1override func viewWillAppear(_ animated: Bool) {
2    super.viewWillAppear(animated)
3    tabBarController?.tabBar.isHidden = true
4}
5
6override func viewWillDisappear(_ animated: Bool) {
7    super.viewWillDisappear(animated)
8    tabBarController?.tabBar.isHidden = false
9}

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:

swift
1import UIKit
2
3final class RootTabBarController: UITabBarController {
4    override func viewDidLoad() {
5        super.viewDidLoad()
6
7        let home = HomeViewController()
8        home.title = "Home"
9        home.navigationItem.rightBarButtonItem = UIBarButtonItem(
10            title: "Details",
11            style: .plain,
12            target: home,
13            action: #selector(HomeViewController.showDetails)
14        )
15
16        let homeNav = UINavigationController(rootViewController: home)
17        homeNav.tabBarItem = UITabBarItem(title: "Home", image: nil, tag: 0)
18
19        let settings = UIViewController()
20        settings.view.backgroundColor = .systemGray6
21        settings.title = "Settings"
22        let settingsNav = UINavigationController(rootViewController: settings)
23        settingsNav.tabBarItem = UITabBarItem(title: "Settings", image: nil, tag: 1)
24
25        viewControllers = [homeNav, settingsNav]
26    }
27}

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 hidesBottomBarWhenPushed for screens pushed inside a navigation stack.
  • Set the property before calling pushViewController.
  • Prefer automatic UIKit behavior over manual tabBar.isHidden toggling.
  • 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
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track 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.

Browse interview questions

All Rights Reserved.