我试图在我的应用程序中使用透明的选项卡栏,以便用户可以看到选项卡栏后面的uitableview
。
我已经看过这里的所有主题,但还没有成功。
我的 AppDelegate 中有以下代码:
UITabBar *tabBar = [self.tabBarController tabBar];
if ([tabBar respondsToSelector:@selector(setBackgroundImage:)])
{
tabBar.opaque = NO;
tabBar.alpha = 0.8;
[[UITabBar appearance] setTintColor:[[UIColor alloc] initWithRed:0.0 green:0 blue:0 alpha:0.9]];
[tabBar setBackgroundImage:[UIImage imageNamed:@"transparent-tabbar.png"]];
}
我只是没有成功禁用选项卡栏的默认黑色背景。
我错过了什么?
顺便说一下,文件transparent-tabbar.png是: http://www.fastup.co.il/images/49382332.png
谢谢。
最佳答案
这里的问题不是你无法设置图像,或者你无法摆脱黑色,问题是在 UITabBarController
中,你添加的 View Controller 没有到达 后面UITabBar
所以出现的问题是 UITabBar
下面有一个黑色 View ,所以即使你删除 tabBar,你看到的也是一个黑色 View (尝试设置 tabBar.hidden = 是;
)
解决方法是将 tabBar
的 superView 设置为颜色
tabBar.superview.backgroundColor = [UIColor whiteColor];
这可以解决您的问题
关于iOS 透明 uitabbar 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11176643/