UITabBarBackgroundView

UITabBarBackgroundView

我一直在尝试制作透明的tabBar背景,但是存在名为UITabBarBackgroundView的东西,并且背景为白色。
我该如何访问?

ios - 如何访问UITabBarBackgroundView-LMLPHP

最佳答案

我认为没有直接的方法可以做到这一点。您将不得不在此处创建一个透明的幻觉。一种方法是在标签栏中设置图像。您可以在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"]];

关于ios - 如何访问UITabBarBackgroundView,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33103295/

10-09 06:31