UITabBarの各アイテムに一意の画像を追加しようとして数時間苦労しました(タブセパレーターが正しく表示され、左右にセパレーターがないため)。
アプリデリゲートにある次のコードは、アイテムを奇妙な方法で下部に表示します。また、タイトルラベルを削除したいと思います。正しいアプローチは何でしょうか?これは私を夢中にさせています。
UIImage *selectedImage0 = [UIImage imageNamed:@"home-tab-active"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"home-tab"];
UIImage *selectedImage1 = [UIImage imageNamed:@"guide-tab-active"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"guide-tab"];
UIImage *selectedImage2 = [UIImage imageNamed:@"search-tab-active"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"search-tab"];
UIImage *selectedImage3 = [UIImage imageNamed:@"favorites-tab-active"];
UIImage *unselectedImage3 = [UIImage imageNamed:@"favorites-tab"];
UIImage *selectedImage4 = [UIImage imageNamed:@"locations-tab-active"];
UIImage *unselectedImage4 = [UIImage imageNamed:@"locations-tab"];
// The Tab Bar
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBarItem *item0 = [tabBarController.tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBarController.tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBarController.tabBar.items objectAtIndex:2];
UITabBarItem *item3 = [tabBarController.tabBar.items objectAtIndex:3];
UITabBarItem *item4 = [tabBarController.tabBar.items objectAtIndex:4];
[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
[item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
[item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
[item3 setFinishedSelectedImage:selectedImage3 withFinishedUnselectedImage:unselectedImage3];
[item4 setFinishedSelectedImage:selectedImage4 withFinishedUnselectedImage:unselectedImage4];