我想更改 tabBar
中的项目颜色,而不是为未选择的项目添加文本等等 长期以来一直在搜索它,但我没有找到。我刚刚找到这段代码,它不会改变项目或图像颜色,只会改变文本。
默认颜色是灰色,我想更改它。
这是我找到的代码:
UITabBar.appearance().barTintColor = UIColor(redRGB: 93, greenRGB: 175, blueRGB: 228)
UITabBar.appearance().tintColor = UIColor .redColor()
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.whiteColor()], forState:.Normal)
最佳答案
尝试使用 google 进行搜索。没有认真尝试。
针对您的问题。什么是灰色? UITabbaritems 在 Storyboard中是标准的灰色。
你可以使用
var image : UIImage? = UIImage(named:"myImage.png").imageWithRenderingMode(.AlwaysOriginal)
选项 Always original 可使图像保持原样,不会变灰。
关于xcode - 如何在 tabBar swift 中更改项目或图像颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36157819/