修改TabBarViewController上标题字体颜色

时间:2023-03-09 18:14:05
修改TabBarViewController上标题字体颜色

修改TabBarViewController上标题字体颜色

UINavigationController *newNavVc = [[UINavigationController alloc]init];

newNavVc.title = title;

newVc.title = title;

//设置TabBar上标题的字体颜色

NSMutableDictionary *dictAttr = [NSMutableDictionary dictionary];

//dictAttr[NSForegroundColorAttributeName] = [UIColor orangeColor];

//dictAttr[NSFontAttributeName]=[UIFont systemFontOfSize:13];

  [dictAttr setObject:[UIColor orangeColor] forKey:NSForegroundColorAttributeName];

[newNavVc.navigationBar setTitleTextAttributes:dictAttr];

newVc.tabBarItem.title = title;

newVc.tabBarItem.image = image;

newVc.tabBarItem.selectedImage = selectImg;

[newNavVc addChildViewController:newVc];

//TabBar上的文字选中时变橙色

[newVc.tabBarItem setTitleTextAttributes:dictAttr forState:UIControlStateSelected];

[self addChildViewController:newNavVc];