ios - 如何访问 UITabBarBackgroundView

标签 ios objective-c xcode

我一直在尝试制作透明的 tabBar 背景,但是存在一个名为 UITabBarBackgroundView 的东西并且具有白色背景。 我怎样才能访问它?

enter image description here

最佳答案

我认为没有直接的方法可以做到这一点。你必须在这里创造一种透明的错觉。一种方法是在标签栏中设置图像。您可以在 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/

相关文章:

ios - 从 Xcode 6 重新构建应用程序时出现 OSStatus 错误 2003334207

ios - 从 View 中删除 UITapGestureRecognizer 而没有指向它的强指针

ios - didUpdateLocations 在 Swift 3 中不起作用

ios - 是否应该为 Swift 类添加前缀以避免潜在的 Objective-C 兼容性冲突问题

ios - 核心数据 : suggestions for model design

ios - 未找到 Metal 内核函数

iphone - 我在哪里可以找到iphone项目中的资源文件(css,js ..)

ios - AB地址簿内存泄漏

ios - Meteor Cordova 启动时间慢得离谱?

objective-c - 在项目中全局声明 UIColor