使用系统UITabbarItem自定义图片显示原本颜色和自定义文字颜色

。。。。。。

ThirdViewController *thirdVC = [[ThirdViewControlleralloc]initWithTitle:@"搜索信息"];

//设置tabbarItem 的图片显示原图颜色;

thirdVC.tabBarItem = [[UITabBarItemalloc]initWithTitle:@"搜索"image:[[UIImageimageNamed:@"login_usernick"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImageimageNamed:@"login_usernick_highlighted"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

//一句话改变图片和文字的颜色均为红色选中时候

//    [[UITabBar appearance]setTintColor:[UIColor redColor]];

//只是设置TabBarItem的字体颜色

[[UITabBarItemappearance] setTitleTextAttributes:[NSDictionarydictionaryWithObject:[UIColorblackColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateNormal];

[[UITabBarItemappearance] setTitleTextAttributes:[NSDictionarydictionaryWithObject:[UIColorredColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateSelected];

RootNavgationController*nav3 = [[RootNavgationControlleralloc]initWithRootViewController:thirdVC];

NSArray *VCs= [NSArray arrayWithObjects:nav1,nav2,nav3, nil];

tabControl.viewControllers = VCs;

self.window.rootViewController = tabControl;

上一篇:js验证输入的是否是数字,小数保留几位小数


下一篇:Python基础06_list