I would like to change the TabBar Item when the user is logged in or not.
For example: I have 5 different tabBar elements, all created storyboards.
Now I want to change the tarBar with index 2 (or tag == 2) when the user does not have an account. I would like to load another rootViewController. RootViewController is no longer an element of my TabBar, I would load a completely different controller.
What is the best way to do this? I can simply change the icon with:
self.tabBar.items![0].selectedImage = UIImage(named: "icon_cal_grey")
But how to change rootViewController?
Should I do it here?
override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) { if item.tag == 1 {
Or do you need to create a UINavigationController as a RootViewController and load the "correct" ViewController here as a RootViewController?
source share