iphone - tabbar set imagetintcolor (offstate)

喜欢而已 提交于 2019-12-24 06:48:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!