我正在尝试创建一个标签栏透明(或看起来透明)的应用程序。为此,我在 View 中使用图像的一部分。并将剩余部分设置为选项卡栏的背景。问题是标签栏显示为较暗的阴影。我现在没有主意了。 以下是屏幕截图
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabbar_bg.png"]];
self.tabBar.backgroundColor=[UIColor whiteColor];
[self.tabBar insertSubview:imgView atIndex:1];
// [self.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"transp.png"]];
// [self.tabBar setSelectedImageTintColor:[UIColor clearColor]];
[[UITabBar appearance] setTintColor:[UIColor clearColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor clearColor]];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"transp.png"]];
上面是我在自定义 UITabBarController
类的 viewDidLoad
中尝试过的代码。 “tabbar_bg.png”是用作选项卡栏背景的图像,“transp.png”是用作选择指示符图像的透明图像。
感谢您的帮助。
最佳答案
尝试
[self.tabBar setBackgroundImage:[UIImage new]];
这个技巧也适用于 UINavigationBar
。
关于ios - 自定义透明UITabBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14848361/