1

I'm stacked with so standart question, but can't find any working example.

I have TabBar(added at storyboard) at my app, and it looks like [Home, Log In, ...]. And the point is about second TabBarItem. There could be 2 cases:

1) user logged in - tabBarItem's title shown as "Profile" and user should be redirecting to ProfileViewController, which is actually a navigation view controller

2) user not logged in - title should be "Log In" and destination is LoginViewController

Please help me find solution for this.

nastassia
  • 807
  • 1
  • 12
  • 31

1 Answers1

1

You need

class CustomTab:UITabBarController {

  override func awakeFromNib()
    super.awakeFromNib()

    let home = ///

    if userLoggedIn {

       let profile = //

       self.viewControllers = [home,profile]

    }
    else {

       let login = //

       self.viewControllers = [home,login]
    }

    tabBar.items?[1].title = userLoggedIn  ? "Profile" :"Login"

  }
}
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87