【发布时间】:2013-10-01 19:57:22
【问题描述】:
(注意:我看到关于 SO 有几个类似的问题,但它们似乎都没有解决我想要更改自定义和系统 UITabBarItems 的未选择外观的具体问题。)
我在 iOS7 中工作。我有一个带有一些按钮的 UITabBar。其中一些是我的按钮,一些是系统按钮。示例:
UITabBarItem *searchButton = [[UITabBarItem alloc] initWithTabBarSystemItem: UITabBarSystemItemSearch tag: navSearchItem];
UITabBarItem *bookMkButton = [[UITabBarItem alloc] initWithTabBarSystemItem: UITabBarSystemItemBookmarks tag: navBookmarksItem];
UITabBarItem *homeButton = [[UITabBarItem alloc] initWithTitle: @"Home" image: [self tabBarImageNamed: @"home-tab"] tag: navHomeItem];
UITabBarItem *setingButton = [[UITabBarItem alloc] initWithTitle: @"Settings" image: [self tabBarImageNamed: @"settings-tab"] tag: navSettingsItem];
navTabBar.items = @[ searchButton, homeButton, bookMkButton, setingButton];
我可以很容易地设置选定按钮的色调,使用:
[[UITabBar appearance] setSelectedImageTintColor: MY_FAVORITE_COLOR];
我可以将未选中的按钮文本颜色设置为白色:
[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, nil]
forState: UIControlStateNormal];
我想要做的是将 UNSELECTED 按钮的图像色调设置为白色。我可以很容易地设置未选择的图像,但这仅适用于 my 按钮。我也想为系统按钮执行此操作。也就是说,我希望我的搜索和书签按钮也是未选中的白色。
如果我尝试重新创建他们的图标来制作自定义按钮,我很确定 Apple 会抱怨。文档非常具体,我们不应该做任何与 Apple 图标相似的事情。
提示?
谢谢!
编辑:我想要 unselected=white 的原因是,在我设计的背景下,默认的灰色会使图标/文本很难看。
【问题讨论】:
标签: ios ios7 uitabbaritem uiappearance