iphone - iOS 7 中的 UITabBar 色调

标签 iphone ios objective-c uikit

选择选项卡时,如何指定图像的色彩?

我试过了,但是没用:

[[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/

相关文章:

ios - 如何旋转 UIScrollView?

带有 Swift 的 iOS : App crashes on UITableView scroll down event

ios - [self addSubview] 和 [self.contentview addSubView] 中的服装 UITableViewCell 有什么区别?

ios - Google Analytics for Mobile Apps iOS SDK v3 事件跟踪

android - 适用于 iOS 和 Android 中的 native 移动应用程序的性能测试工具

iphone - 第二个 View Controller 中的 UIButton - Touch Up Inside 不起作用(Touch Down 确实如此)

iphone - 延迟后使用选择器执行多个操作

objective-c - 属性复制在Cocoa框架中意味着什么?(如UITabBar的items属性)

objective-c - NSNumber 的格式化绝对值

objective-c - "Block pointer to non-function type is invalid"