2015-06-23 165 views
0

我很難嘗試更改我的UITabBarItem的圖標顏色。我用下面的代碼初始化所有參數:更改UITabBarItem圖像的顏色

// 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) 
    } 

我在這裏丟失了什麼嗎? FYI:只是的XCode測試版雨燕2.0

+0

會發生什麼?出了什麼問題? – vrwim

回答

0

打已經回答here但在短期,點擊您要更改標籤欄項目,您可以在故事板中添加一個新的運行屬性,這將改變整個項目(圖像&文本)被選中時。