3つのタブすべてに対して2つの画像を作成する必要があります。一方は選択されておらず、もう一方は選択されています。
その後、appdelegate.mファイルに以下のコードを記述します
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.searchArray = [[NSMutableArray alloc]init];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
viewController1 *view1 = [[[viewController1 alloc] initWithNibName:@"viewController1" bundle:nil] autorelease];
view1.tabBarItem.image = [UIImage imageNamed:@"tab-selected-1"];
view1.tabBarItem.title = @"Title1";
viewController2 *view2 = [[[viewController2 alloc] initWithNibName:@"viewController2" bundle:nil] autorelease];
view2.tabBarItem.image = [UIImage imageNamed:@"tab-selected-2"];
view2.tabBarItem.title = @"Title2";
viewController3 *view3 = [[[viewController3 alloc] initWithNibName:@"viewController3" bundle:nil] autorelease];
view3.tabBarItem.image = [UIImage imageNamed:@"tab-selected-3"];
view3.tabBarItem.title = @"Title3";
self.tabBarController.viewControllers = [NSArray arrayWithObjects:view1, view2, view3, nil];
UITabBarItem *tabBarItem1 = [[self.tabBarController.tabBar items] objectAtIndex:0];
[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"tab-selected-1.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab-unselected-1.png"]];
UITabBarItem *tabBarItem2 = [[self.tabBarController.tabBar items] objectAtIndex:1];
[tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"tab-selected-2.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab-unselected-2.png"]];
UITabBarItem *tabBarItem3 = [[self.tabBarController.tabBar items] objectAtIndex:2];
[tabBarItem3 setFinishedSelectedImage:[UIImage imageNamed:@"tab-selected-3.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab-unselected-3.png"]];
return YES;
}
これを試してみてくださいあなたの問題は確実に解決しました。幸運を祈ります