3

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?

Ronnie L
  • 123
  • 1
  • 3
  • 9
  • have you tried removing the item at index 4 ? – Leo Dabus Sep 12 '16 at 22:00
  • 1
    Thanks Leo! I was able to find an example where they removed it. Half of my problem was finding the correct word to search for. I kept searching for "hide" and "disable" but the correct word was "remove". – Ronnie L Sep 12 '16 at 22:08

1 Answers1

1

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
    }
}
Allen
  • 2,979
  • 1
  • 29
  • 34