Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding a tab in a tab bar in iOS (Swift)

Tags:

ios

swift

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.

like image 942
James Lee Avatar asked Oct 31 '22 00:10

James Lee


1 Answers

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
    }

}
like image 164
José Avatar answered Nov 15 '22 07:11

José