0

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

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

2 回答 2

0

The easiest way to make a tab bar transparent is by setting the tab bar background image to a transparent image in the interface builder. You can get a transparent png image whose height and width is equal to the tab bar's from the net.

Note: By changing the alpha value, you actually end up dimming the tab bar's icons as well. Make sure this is what you want, otherwise using a transparent background image is a better option.

于 2014-05-31T10:24:04.313 回答
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];
}

这个链接也将帮助你

于 2013-03-27T13:09:46.463 回答