我现在已经挣扎了几个小时,试图为我的 UITabBar 中的每个项目添加一个 uniqe 图像(因为我希望标签分隔符正确显示,并且在最左边和最右边没有分隔符)。
我的应用程序委托中的以下代码在底部以一种奇怪的方式显示项目。也想删除标题标签。什么是正确的方法?这真让我抓狂..
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];