你必須爲每一個標籤項中選擇圖像。下面的代碼爲我工作
if ([[tabBarController.tabBar.items objectAtIndex:0] respondsToSelector:@selector(setFinishedSelectedImage:withFinishedUnselectedImage:)]) {
[[tabBarController.tabBar.items objectAtIndex:0] setFinishedSelectedImage:[UIImage imageNamed:@"blabla1.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"bleble1.png"]];
[[tabBarController.tabBar.items objectAtIndex:1] setFinishedSelectedImage:[UIImage imageNamed:@"blabla2.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"bleble2.png"]];
[[tabBarController.tabBar.items objectAtIndex:2] setFinishedSelectedImage:[UIImage imageNamed:@"blabla3.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"bleble3.png"]];
[[tabBarController.tabBar.items objectAtIndex:3] setFinishedSelectedImage:[UIImage imageNamed:@"blabla4.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"bleble4.png"]];
}
該代碼應該放在哪裏?我可以在UITabBarViewController顯示的視圖控制器的'viewDidLoad'中使用它嗎? – neutrino 2013-03-20 11:32:15
當然!有用!我會接受你的回答。非常感謝你! – neutrino 2013-03-20 11:34:59
記住,在iOS7中,您需要使用此代碼的故事板中的圖標的SELECTED版本 – JulianB 2013-10-22 13:28:28