我当前的标签栏如下所示:
我的代码如下:
-(void)startTabBar{ self.tabBarController = [[UITabBarController alloc] init]; TAB_1 *tab_1 = [[TAB_1 alloc]init]; TAB_2 *tab_2 = [[TAB_2 alloc]init]; TAB_3 *tab_3 = [[TAB_3 alloc]init]; [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor blackColor],NSForegroundColorAttributeName,nil] forState:UIControlStateNormal]; [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],nil] forState:UIControlStateSelected]; NSArray* controllers = [NSArray arrayWithObjects:tab_1,tab_2,tab_3,nil]; self.tabBarController.viewControllers = controllers; self.window.rootViewController = self.tabBarController; }
我想做的是:
普通标签:标签标题应为黑色,但只有图标图像应为黑色.预期的标签应该是:
选定选项卡:选项卡标题应为红色,但只有图标图像应为红色.预期的标签应该是:
标签栏颜色:使整个tabBar颜色更透明,颜色相同
有人可以帮忙吗?
解决方法
这可以满足您的要求:
[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]]; [[UITabBar appearance] setAlpha:0.25];