(注意:我看到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的图标类似的东西. …
这是我对标签栏项目的设置:

但是,当单击应用程序内的项目时,未显示1051-id-badge选择的图像,而是显示任何内容:

我的设置有问题吗?有任何想法吗?
在iOS 7之前我使用过
[[UITabBar appearance] setTintColor:[UIColor redColor]];
Run Code Online (Sandbox Code Playgroud)
但是现在它只绘制了所选项目,我已经阅读了一些建议,但我无法完成如何操作,我也使用了它:
[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"openbookwp4.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"openbookwp4.png"]];
Run Code Online (Sandbox Code Playgroud)
这把我想要的图标和我想要的颜色放在一起,但只有在我选择该标签后,例如,当我打开应用程序时,标签看起来正常,但在我按下第二个标签并返回第一个标签后,第二个标签现在有我想要的颜色.没有图像很难解释,但我无法发布图像......