首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >透明UITabBar

透明UITabBar
EN

Stack Overflow用户
提问于 2014-12-21 13:27:04
回答 4查看 4.7K关注 0票数 2

我已经子类UITabBar,我需要它是透明的。就像这样:

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

它只改变了酒吧的颜色,但酒吧仍然是不透明的。

请帮帮忙。我试过很多不同的方法,但都没有用。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2014-12-21 13:50:06

尝尝这个

代码语言:javascript
复制
//  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];

这是结果

票数 4
EN

Stack Overflow用户

发布于 2017-07-21 18:35:00

下面是一个基于AnupamChugh的答案的解决方案

  1. 为IBOutlet中的选项卡条创建一个UITabBarController
  2. 使用该选项卡将选项卡条设置为透明。 类AppTabBarController: UITabBarController { @IBOutlet弱变量mTabBar: UITabBar!覆盖func viewDidLoad() { super.viewDidLoad() mTabBar.backgroundColor = UIColor.clear mTabBar.backgroundImage = UIImage() mTabBar.shadowImage = UIImage() //移除边框

票数 4
EN

Stack Overflow用户

发布于 2016-08-09 13:38:16

代码语言:javascript
复制
UITabBar.appearance().backgroundColor=UIColor.clearColor()
UITabBar.backgroundImage = UIImage()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27589797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档