我想要将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