iOS 7中的UITabBar色调 [英] UITabBar tint in iOS 7
问题描述
如果选择和取消选中标签,我如何指定图像的色调?
How can i specify the tint of images when a tab is selected and unselected?
我试过这个但它不起作用:
I have tried this but it doesnt work:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
这使得所选图像色调为红色(不是绿色)和未选择的色调灰色(不是红色)。 / p>
This makes the selected image tint red(not green) and unselected tint gray (not red).
推荐答案
您可以为选定和未选择的标签栏按钮设置色调颜色,如下所示:
You can set the tint color for selected and unselected tab bar buttons like this:
[[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
第一行设置未选择的颜色 - 在本例中为红色 - 通过设置UIView的tintColor来设置它在标签栏中。请注意,这仅设置未选择图像的色调颜色 - 它不会更改其下方文本的颜色。
The first line sets the unselected color - red in this example - by setting the UIView's tintColor when it's contained in a tab bar. Note that this only sets the unselected image's tint color - it doesn't change the color of the text below it.
第二行设置标签栏的所选图像色调颜色绿色。
The second line sets the tab bar's selected image tint color to green.
这篇关于iOS 7中的UITabBar色调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!