选择选项卡时,如何指定图像的色彩?
我试过了,但是没用:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
这会使选定的图像变成红色(不是绿色),而未选择的图像变成灰色(不是红色)。
最佳答案
您可以像这样为选中和未选中的标签栏按钮设置色调颜色:
[[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
第一行通过设置标签栏中包含的 UIView 的 tintColor 来设置未选中的颜色(本例中为红色)。请注意,这只会设置未选中图像的色调 - 它不会更改其下方文本的颜色。
第二行将标签栏的选定图像色调颜色设置为绿色。
关于iphone - iOS 7 中的 UITabBar 色调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19231074/