- 添加tabar控制器的子控制器,设置属性的时候
问题:
1.选中的图片被渲染
2.选中标题颜色:黑色 标题字体大
3.按钮显示不出来
//标题1
essenceNav.tabBarItem.title = @"标题1";
essenceNav.tabBarItem.image = [UIImage imageNamed:@"标题1"];
essenceNav.tabBarItem.selectedImage = [UIImage imageNamed:@"标题1"];
[self addChildViewController:essenceNav];
UIStoryboard *stroy = [UIStoryboard storyboardWithName:NSStringFromClass([BUJMeVC class]) bundle:nil];
BUJMeVC *meVC = [stroy instantiateInitialViewController];
BDJNavigationController *meNav = [[BDJNavigationController alloc] initWithRootViewController:meVC];
[self addChildViewController:meNav];
处理Tabbar颜色和字体
/ 只会调用一次
+ (void)load
{
// UITabBarItem *item = [UITabBarItem appearanceWhenContainedInInstancesOfClasses:<#(nonnull NSArray<Class<UIAppearanceContainer>> *)#>];io9
UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn: self, nil];
// 设置按钮选中标题的颜色:富文本:描述一个文字颜色,字体,阴影,空心,图文混排
// 创建一个描述文本属性的字典
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
dic[NSForegroundColorAttributeName] = [UIColor blackColor];
[item setTitleTextAttributes:dic forState:UIControlStateSelected];
//设置字体大小// 设置字体尺寸:只有设置正常状态下,才会有效果
NSMutableDictionary *fontDic = [NSMutableDictionary dictionary];
fontDic[NSFontAttributeName] = [UIFont systemFontOfSize:8];
[item setTitleTextAttributes:fontDic forState:UIControlStateNormal];
}