问题
I see that there is [tabBar setSelectedImageTintColor:[UIColor]]
which is great, but how do I set the imagetintcolor for the offstate? I can't seem to find a [tabBar setImageTintColor]
or [tabBar setUnSelectedImageTintColor]
.
回答1:
Take a look at the "Managing the Finished and Selected Image" task's section of the docs of UITabBarItem.
回答2:
And for a quick cut 'n paste:
NSArray *tabBarImages = [[NSArray alloc] initWithObjects:@"tab_a.png",
@"tab_b.png",
@"tab_c.png",
@"tab_d.png",
@"tab_e.png",
nil];
for (uint i=0;i<[_tabBarController.tabBar.items count];i++)
{
UITabBarItem *uitbi = [_tabBarController.tabBar.items objectAtIndex:i];
NSString *imageRef = [tabBarImages objectAtIndex:i];
[uitbi setFinishedSelectedImage:[UIImage imageNamed:imageRef] withFinishedUnselectedImage:[UIImage imageNamed:imageRef]];
}
回答3:
For changing the look and feel of the buttons to that level of detail, you are going to have to implement your own custom UITabBar. Here's a good reference:
http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/
来源:https://stackoverflow.com/questions/10862778/iphone-tabbar-set-imagetintcolor-offstate