Reputation: 123
I have a five tab, tab bar controller in my app, and I want to only show the 5th item if a manager is logged into the app (instead of employee).
I currently have this code which disables the 5th item but I can still see it (its just grayed out and is not clickable).
self.tabBarController!.tabBar.items![4].enabled = false
Is there a way to only show the first four items and evenly space them if a non manager is logged in?
Upvotes: 3
Views: 4130
Reputation: 3207
Swift 3
if let tabBarController = self.tabBarController {
let indexToRemove = 3
if indexToRemove < tabBarController.viewControllers!.count {
var viewControllers = tabBarController.viewControllers
viewControllers?.remove(at: indexToRemove)
tabBarController.viewControllers = viewControllers
}
}
Upvotes: 1