I'm having an hard time trying to change the color of my UITabBarItem
's icon. I used the code below to initialize all the parameters:
// Settings Tab
tabBarController?.tabBar.translucent = false
tabBarController?.tabBar.barTintColor = dark_color
let titoli:[String] = ["Feed","Categorie","Info"]
for (var i:Int=0; i<titoli.count; i++){
let tab:UITabBarItem? = tabBarController?.tabBar.items![i] as UITabBarItem?
tab?.image = UIImage(named: titoli[i])
tab?.title = titoli[i]
tab?.setTitleTextAttributes(NSDictionary(object: UIColor.whiteColor(), forKey: NSForegroundColorAttributeName) as? [String:AnyObject], forState: UIControlState.Selected)
tab?.setTitleTextAttributes(NSDictionary(object: UIColor(red: 0, green: 0, blue: 0, alpha: 0.6), forKey: NSForegroundColorAttributeName) as? [String:AnyObject], forState: UIControlState.Normal)
}
Am I missing something here? FYI: just playing with XCode Beta and Swift 2.0
Already answered here but in short, click on the tab bar item you wish to change and you can add a new runtime attribute in the Storyboard which will change the entire item (image & text) when selected.