Before I updated to Swift 3, this worked perfectly (besides isEnabled was just enabled). This code is in my UITabBarController ViewDidLoad function. The if is never met so therefore the items are never set to true.
How do I access the items as I want the tabs to be greyed about until a variable is selected?
if  let arrayOfTabBarItems = self.tabBar.items as AnyObject as? NSArray,let tabBarItem = arrayOfTabBarItems[1] as? UITabBarItem {
    tabBarItem.isEnabled = true
}
                Try this:
let arrayOfTabBarItems = self.tabBar.items
if let barItems = arrayOfTabBarItems, barItems.count > 0 {
  let tabBarItem = barItems[0]
  tabBarItem.isEnabled = true
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With