嗨,我正在将我的应用程序从 ios 6.1 迁移到 7,该应用程序包含一个标签栏控制器,在 ios6 上运行良好,但是当我在 ios 7 上运行它时,5 个标签栏项目中有 4 个不显示所选图像,这很奇怪由于一个显示正确,而其他显示不正确,我正在使用情节提要,我无法使用“imageWithRenderingMode:”,因为我仍在 xcode 4.6 上执行此操作,所以我想仅在 xcode 4.6 中对其进行纠正并能够运行在ios7上,给出了tabbarcontroller的代码,如有错误请见谅..
- (void)customizeTabbarBackgroundImages:(UITabBarController *)tabbarController
{
//background of tabbar
[tabbarController.tabBar setBackgroundImage:[UIImage imageNamed:@"tabbarBackground.png"]];
//background for selected item
[[tabbarController tabBar] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar-selection-background.png"]];
//keep the item at index 2 as selected item
tabbarController.selectedIndex = 2;
}
- (void)customizeTabbarItemImages:(UITabBarController *)tabbarController
{
{
//Index - Favourites
[[tabbarController.tabBar.items objectAtIndex:0] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-favourites-icon-down.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-favourites-icon.png"]];
//Index - Search
[[tabbarController.tabBar.items objectAtIndex:1] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-search-icon-down.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-search-icon.png"]];
//Index - Icon
[[tabbarController.tabBar.items objectAtIndex:2] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-random-button"]withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-random-button"]];
//Index - Profile
[[tabbarController.tabBar.items objectAtIndex:3] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-profile-icon-down.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-profile-icon.png"]];
//Index - Settings
[[tabbarController.tabBar.items objectAtIndex:4] setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-settings-icon-down.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-settings-icon.png"]];
}
}