Reputation: 897
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.
Upvotes: 1
Views: 55
Reputation: 100503
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"
}
}
Upvotes: 1