4

As the title states, how do you hide/show a tab in a tab bar where a tab bar controller is programmatically?

Or is there a better way to do this, since I want to show a certain tab containing a certain view depending on the user that logs in.

James Lee
  • 305
  • 1
  • 11

2 Answers2

4

Assuming that you have a subclass of UITabBarController:

final class YourSubClass: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        viewControllers?.remove(at: 0) // remove the first tab, tab index starts with 0
    }

}
José
  • 3,112
  • 1
  • 29
  • 42
-1

Use the following code to hide/show tab bar in ios

var tab = UITabBarController()
override func viewDidLoad()
{
    super.viewDidLoad()
    tab.tabBar.hidden = true //set false to show
}  
ADK
  • 139
  • 10