答案 0 :(得分:1)
我认为没有直接的方法可以做到这一点。你必须在这里创造一种透明的幻觉。一种方法是在标签栏中设置图像。您可以在UITabBarController
上添加以下类别并将其命名为
- (void) setBackgroundImage:(UIImage *)image
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];
imageView.backgroundColor = [UIColor colorWithPatternImage:image];
[self.view addSubview:imageView];
[self.view sendSubviewToBack:imageView];
[self.view setOpaque:NO];
[self.view setBackgroundColor:[UIColor clearColor]];
}
另一种方式(仅限图像方式:)):
UIImage *tabBarBackground = [UIImage imageNamed:@"tabBarBackground.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:127.0/255.0 green:186.0/255.0 blue:235.0/255.0 alpha:1.0]];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabBarItemSelected.png"]];