【问题标题】:How to make TabBar transparent如何使 TabBar 透明
【发布时间】:2013-03-26 20:11:11
【问题描述】:

我想使标签栏透明并保留图标。因此,当您查看它时,标签栏上的图标看起来就像它们本身一样。我这样做的代码是什么?现在这是我的代码

 UIImage* tabBarBackground = [UIImage imageNamed:@""];
 [[UITabBar appearance] setBackgroundImage:tabBarBackground];
 [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@""]];

【问题讨论】:

    标签: xcode background transparency tabbar


    【解决方案1】:

    试试这个代码

    - (void)viewDidLoad 
    {
      [super viewDidLoad];
    
      CGRect frame = CGRectMake(0.0, 0, self.view.bounds.size.width, 48);
    
      UIView *trans_view = [[UIView alloc] initWithFrame:frame];
    
      [trans_view setBackgroundColor:[[UIColor alloc] initWithRed:0.0
                                           green:0.0
                                            blue:0.0
                                           alpha:0.5]];//you can change alpha value also
    
      [tabBar1 insertSubview:trans_view atIndex:0];//tabBar1 = your tabbar reference
      [trans_view release];
    }
    

    这个link也会帮助你

    【讨论】:

      【解决方案2】:

      使标签栏透明的最简单方法是在界面构建器中将标签栏背景图像设置为透明图像。 你可以从网上得到一个高度和宽度等于标签栏的透明png图片。

      注意:通过更改 alpha 值,您实际上最终也会使标签栏的图标变暗。确保这是您想要的,否则使用透明背景图像是更好的选择。

      【讨论】:

        猜你喜欢
        • 2023-01-27
        • 1970-01-01
        • 1970-01-01
        • 2014-01-25
        • 2020-04-27
        • 2021-11-26
        • 1970-01-01
        • 2020-12-27
        • 2014-01-27
        相关资源
        最近更新 更多