[英]Tab bar background color not changing in ios6
I am working in a project and I need to implement tab bar controller in this. 我正在一个项目中,我需要在其中实现标签栏控制器。 my tab bar background color is black and I used following code for this :
我的标签栏背景颜色是黑色,为此我使用了以下代码:
[[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)];
tabBarItem1.title=@"Home";
tabBarItem2.title=@"Connect";
tabBarItem3.title=@"About";
tabBarItem4.title=@"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];
> >
which is working fine in ios7 but there is no reflection of this line in ios6. 在ios7中工作正常,但在ios6中没有反映这一行。 Is there any thing else that I need to implement or any thing I missed regarding tab bar property in ios6?
关于ios6中的选项卡栏属性,我还需要实现什么还是错过什么吗? Any help will be appreciated.
任何帮助将不胜感激。
Well they changed a lot about colors in iOS 7. Read the human interface guidelines by Apple: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/MobileHIG/index.html 好吧,他们在iOS 7中改变了很多颜色。请阅读Apple的人机界面指南: https : //developer.apple.com/library/ios/documentation/userexperience/conceptual/MobileHIG/index.html
And here is the code: 这是代码:
//check if this is not iOS 7
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
//your code above except last line
//Tint is background in iOS 6 but text color in iOS 7
self.tabBarController.tabBar.tintColor = [UIColor blackColor];
}else{
//your code above
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.