0
我在一個項目中工作,我需要在此實現標籤欄控制器。我的標籤欄的背景色爲黑色,我用這下面的代碼:標籤欄背景顏色不會在ios6中更改
[[UITabBar appearance] setTintColor:[UIColor blackColor]]; UITabBarItem *tabBarItem1 = [tabBarController.tabBar.items objectAtIndex:0]; UITabBarItem *tabBarItem2 = [tabBarController.tabBar.items objectAtIndex:1]; UITabBarItem *tabBarItem3 = [tabBarController.tabBar.items objectAtIndex:2]; UITabBarItem *tabBarItem4 = [tabBarController.tabBar.items objectAtIndex:3]; [ tabBarItem1 setImageInsets:UIEdgeInsetsMake(2,0,-2,0)]; [ tabBarItem2 setImageInsets:UIEdgeInsetsMake(2,0,-2,0)]; [ tabBarItem3 setImageInsets:UIEdgeInsetsMake(2,0,-2,0)]; [ tabBarItem4 setImageInsets:UIEdgeInsetsMake(2,0,-2,0)];
[email protected]"Home";
[email protected]"Connect";
[email protected]"About";
[email protected]"Settings";
[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:139.0/255.0 green:189.0/255.0 blue:208.0 alpha:255.0], UITextAttributeTextColor,
[UIFont fontWithName:@"Arial" size:0.0], UITextAttributeFont,
nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIFont fontWithName:@"Arial" size:0.0], UITextAttributeFont,
nil] forState:UIControlStateSelected];
[tabBarItem1 setFinishedSelectedImage:[self imageWithImage:[UIImage imageNamed:@"home_icon_selected.png"] scaledToSize:CGSizeMake(24, 18)] withFinishedUnselectedImage:[self imageWithImage:[UIImage imageNamed:@"home_icon.png"] scaledToSize:CGSizeMake(24, 18)]];
[tabBarItem2 setFinishedSelectedImage:[self imageWithImage:[UIImage imageNamed:@"connect_icon_selected.png"] scaledToSize:CGSizeMake(24, 18)] withFinishedUnselectedImage:[self imageWithImage:[UIImage imageNamed:@"connect_icon.png"] scaledToSize:CGSizeMake(24, 18)]];
[tabBarItem3 setFinishedSelectedImage:[self imageWithImage:[UIImage imageNamed:@"about_icon_selected.png"] scaledToSize:CGSizeMake(24, 18)] withFinishedUnselectedImage:[self imageWithImage:[UIImage imageNamed:@"about_icon.png"] scaledToSize:CGSizeMake(24, 18)]];
[tabBarItem4 setFinishedSelectedImage:[self imageWithImage:[UIImage imageNamed:@"settings_icon_selected.png"] scaledToSize:CGSizeMake(24, 18)] withFinishedUnselectedImage:[self imageWithImage:[UIImage imageNamed:@"settings_icon.png"] scaledToSize:CGSizeMake(24, 18)]];
self.tabBarController.tabBar.tintColor = [UIColor whiteColor];
>
這是工作在ios7罰款,但沒有這條線在iOS6的反射。還有什麼我需要實現或者我錯過了關於ios6中標籤欄屬性的任何事情?任何幫助將不勝感激。