【问题标题】:Custom transparent UITabBar自定义透明UITabBar
【发布时间】:2013-02-13 07:19:27
【问题描述】:

我正在尝试创建一个标签栏透明(或看起来透明)的应用。为此,我在视图中使用图像的一部分。并将剩余部分设置为标签栏的背景。问题是标签栏出现较暗的阴影。我现在没有主意了。 下面是截图

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”是用作 selectionIndicator 图像的透明图像。

感谢您的帮助。

【问题讨论】:

  • 透明的标签栏有什么用......用户永远不会知道它。
  • 只有标签栏是透明的。标签栏项目图像将可见,使其具有浮动效果。
  • self.tabBar.backgroundColor = [UIColor ClearColor];不会成功吗?
  • 也可以设置uitabbar的alpha [self.tabBar setAlpha:0.5];这将使它半透明。您可以根据自己的选择将其设置为 0.3 或 0.2。 0 将使其透明,1 将使其恢复到原始状态。我希望它有所帮助。
  • alpha 0 也将使其内部控件透明......我建议你尝试 prajwal 给出的解决方案

标签: ios objective-c cocoa-touch uikit uitabbar


【解决方案1】:

试试

[self.tabBar setBackgroundImage:[UIImage new]];

这个技巧也适用于UINavigationBar。

【讨论】:

    【解决方案2】:

    您是否尝试过创建它的子类?

    @implementation TabBarInvisible
    -(id)init
    {
        self = [super init];
        if (self)
        {
            self.opaque = NO;
            self.backgroundColor = [UIColor clearColor];
            self.backgroundImage = nil;
        }
        return self;
    }
    -(void)drawRect:(CGRect)rect
    {
    
    }
    
    @end
    

    【讨论】:

      猜你喜欢
      • 2012-04-21
      • 1970-01-01
      • 1970-01-01
      • 2011-02-03
      • 1970-01-01
      • 1970-01-01
      • 2012-08-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多