2

タブバーが透明な (または透明に見える) アプリを作成しようとしています。このために、ビューで画像の一部を使用しています。そして残りの部分をタブバーの背景に設定します。問題は、タブ バーが暗い色合いで表示されることです。私は今、アイデアがありません。以下はスクリーンショットです

ここに画像の説明を入力

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"]];

viewDidLoad上記は、カスタムUITabBarControllerクラスで試したコードです。「tabbar_bg.png」はタブ バーの背景として使用される画像で、「transp.png」は selectionIndicator 画像として使用される透明な画像です。

助けてくれてありがとう。

4

2 に答える 2

0

そのサブクラスを作成しようとしましたか?

@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
于 2013-09-11T00:03:39.753 に答える