【发布时间】:2014-01-27 13:00:02
【问题描述】:
我的UITabBarController 是从UITabBarController 扩展而来的,iOS7 的背景颜色是半透明的,但在 iOS6 中是黑色的。 iOS6中如何将背景色改为半透明
【问题讨论】:
标签: ios iphone objective-c ios6 ios7
我的UITabBarController 是从UITabBarController 扩展而来的,iOS7 的背景颜色是半透明的,但在 iOS6 中是黑色的。 iOS6中如何将背景色改为半透明
【问题讨论】:
标签: ios iphone objective-c ios6 ios7
您可以设置透明图像
UIImage* tabBarBackground = [UIImage imageNamed:@""];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"trans.png"]];
查看链接
【讨论】:
您是否尝试过使用自定义颜色的 tint 属性,例如
[[UITabBar appearance] setTintColor:[[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.5]];
【讨论】:
有很多方法,但默认在iOS7
[tabBar setTranslucent:YES]; 所以你有 tabBar 的半透明背景但是在iOS6 你手动做
[tabBar setTranslucent:YES];
试试吧,也试试 @Retro's 的答案,另一个选择是
[self.tabBarController.tabBar setBackgroundColor:[UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.6]];
【讨论】:
你可以设置如下。
[self.tabBarController.tabBar setBackgroundColor:
[UIColor whiteColor]];
[self.tabBar setBackgroundColor:[UIColor whiteColor]];
[self.tabBarController.tabBar setTranslucent:NO];
[self.tabBar setTranslucent:NO];
【讨论】: