Oli*_*lie 19 uitabbaritem ios uiappearance ios7
(注意:我看到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];
Run Code Online (Sandbox Code Playgroud)
我可以轻松地设置所选按钮色调,具有:
[[UITabBar appearance] setSelectedImageTintColor: MY_FAVORITE_COLOR];
Run Code Online (Sandbox Code Playgroud)
我可以将未选中的按钮文本颜色设置为白色:
[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, nil]
forState: UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
我想要做的是将UNSELECTED按钮的图像色调颜色设置为白色.我可以很容易地设置未选择的图像,但这只适用于我的按钮.我也想为系统按钮执行此操作.也就是说,我希望我的搜索和书签按钮也可以取消选择 - 白色.
如果我尝试重新创建他们的图标来制作自定义按钮,我很确定Apple会抱怨.这些文档非常具体,我们不应该做任何与Apple的图标类似的东西.
提示?
谢谢!
编辑:我想要取消选择=白色的原因是,在我设计的背景下,默认灰色会使图标/文字在眼睛上变硬.
thg*_*hgc 12
我成功将自定义未选定的UITabBarItem图像设置为白色的唯一方法是使用以下(白色)图像并使用特定的渲染模式加载它
UIImage *tabImage = [[UIImage imageNamed:@"white_tab_item"]
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.tabItem.image = tabImage;
Run Code Online (Sandbox Code Playgroud)
"tabItem"是该类的UITabBarItem Outlet
积分转到Aaron Brager的回答: UITabBarController未选中的图标图像色调
Dan*_*xox -4
应该是:
[[UITabBar appearance] setTintColor:[UIColor whiteColor]]
Run Code Online (Sandbox Code Playgroud)
摘自:iOS自定义UI系列:TabBar & NavBar:http://bit.ly/1ahr9Ao