2013-03-26 29 views
0

我想使tabbar透明并让图标仍然存在。所以当你看它时,tabbar上的图标看起来就像是它们自己的图标。什么是我做这个的代码?现在这是我的代码有如何使TabBar透明

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

回答

0

试试这个代码

- (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也会帮你

0

,使标签栏透明的最简单的方法是通过将标签栏背景图像添加到界面生成器中的透明图像。 你可以得到一个透明的PNG图像,其高度和宽度等于标签栏的净重。

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