我想要將UI標籤欄圖標顏色更改爲值:紅色:0.75,綠色:1.0,藍色:1.0,Alpha:1.0,並在未選中圖標時變爲白色。更改UITabBar圖標的顏色
直到現在我還以爲你這是怎麼做到這一點:
UITabBarItem.appearance().finishedSelectedImage([NSForegroundColorAttributeName: UIColor(red: 0.75, green: 1.0, blue: 1.0, alpha: 1.0)], forState: UIControlState.Selected)
UITabBarItem.appearance().finishedUnselectedImage([NSForegroundColorAttributeName: UIColor.whiteColor()], forState: UIControlState.Normal)
上面的代碼是在我的委託。
現在,我已經把這個代碼:
import UIKit
class UITabBarViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var testImage = UIImage(named: "22274")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
testImageView.tintColor = UIColor.redColor()
testImageView.image = testImage
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
進入我的標籤欄視圖控制器COCCO touch文件。我不知道爲什麼我得到一個錯誤仍然
有沒有你要的顏色,或只是文本的圖像? – 2014-12-13 09:33:02
您設置了色調顏色 – soulshined 2014-12-13 09:38:28
我目前沒有圖像,但我正在談論未來。我可以在「更多」標籤欄圖標中看到它是灰色的,並且它不適合我的藍色背景。 @DánielNagy – 2014-12-13 14:54:42