【发布时间】:2012-06-02 13:47:16
【问题描述】:
我看到[tabBar setSelectedImageTintColor:[UIColor]] 很棒,但是我如何设置 offstate 的 imagetintcolor?我似乎找不到[tabBar setImageTintColor] 或[tabBar setUnSelectedImageTintColor]。
【问题讨论】:
标签: iphone objective-c tabbar
我看到[tabBar setSelectedImageTintColor:[UIColor]] 很棒,但是我如何设置 offstate 的 imagetintcolor?我似乎找不到[tabBar setImageTintColor] 或[tabBar setUnSelectedImageTintColor]。
【问题讨论】:
标签: iphone objective-c tabbar
查看UITabBarItem 文档的“管理完成和选定的图像”任务部分。
【讨论】:
selectedImageTintColor 的文档清楚地说:If you want to also customize the unselected image appearance, you must sent setFinishedSelectedImage:withFinishedUnselectedImage: to individual tab bar items.
对于快速剪切和粘贴:
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]];
}
【讨论】:
为了将按钮的外观和感觉更改为详细程度,您将必须实现自己的自定义 UITabBar。这是一个很好的参考:
http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/
【讨论】: