iOS 透明 uitabbar 不起作用

标签 ios ios5 ios4 uitabbar

我试图在我的应用程序中使用透明的选项卡栏,以便用户可以看到选项卡栏后面的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/

相关文章:

ios - uiscrollview不会更新滚动内容

ios - 如何快速激活操作表按钮?

ios4 - 如何在按下按钮后每秒必须播放简短声音的情况下释放AVAudioPlayer对象

ios - 选择文本字段时向上滑动的 View 消失,点击键盘时消失

iOS:通过电子邮件的 Firebase 邀请不起作用

ios - NSFetchedResultsController 委托(delegate)奇怪的行为

iphone - 通过应用内购买完成购买后,将标志存储在 NSUserDefaults 中是否安全?

ios - iOS5 中 icloud 的核心数据

objective-c - TabBar躲起来了,怎么问都不想回来……

ios4 - 启动增强现实 (AR) 应用程序,例如 Panasonic VIERA AR 设置模拟器