ios - 透明的 UITabBar

标签 ios tabbar

我已经对 UITabBar 进行了子类化,我需要它是透明的。像这样:enter image description here

我试过:[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:79.0f/255.0 green:53.0f/255.0 blue:98.0f/255.0 alpha:0.6f]];

只是改变了条形的颜色,但条形仍然不透明。

请帮忙。我尝试了很多不同的方法,但都没有奏效。

最佳答案

试试这个

//  The color you want the tab bar to be
UIColor *barColor = [UIColor colorWithRed:79.0f/255.0 green:53.0f/255.0 blue:98.0f/255.0 alpha:0.6f];

//  Create a 1x1 image from this color
UIGraphicsBeginImageContext(CGSizeMake(1, 1));
[barColor set];
UIRectFill(CGRectMake(0, 0, 1, 1));
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

//  Apply it to the tab bar
[[UITabBar appearance] setBackgroundImage:image];

这是结果

enter image description here

关于ios - 透明的 UITabBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27589797/

相关文章:

swift - 如何快速更改标签栏的色调颜色?

SwiftUI 2.0 - TabView 标签栏颜色不符合当前的配色方案(深色或浅色模式)

android - 为什么 Tabbar 与按钮重叠时显示白色阴影?

ios - 以编程方式将 Sqlite 表数据导出到 csv 文件 - xcode iOS 5(适用于 ipad 应用程序)

ios - 将 persistenceStoreCoordinator sqlite 文件迁移到新名称

iphone - 覆盖它的 drawRect 时如何显示 UIButton 的标题

ios - 如何将 UITableVewCell 的可访问性特征设置为仅 'link'?

ios - iOS 上的默认文件保护是什么以及如何更改它

iPhone在uiviewcontroller中添加按钮

iphone - iPad 上的选项卡 View 未调整大小