如何修改TabBarItem的title的字体和颜色

2025-04-04 06:24:53
推荐回答(2个)
回答1:

自定义。

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
nil] forState:UIControlStateNormal];
UIColor *titleHighlightedColor = [UIColor greenColor];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
titleHighlightedColor, UITextAttributeTextColor,
nil] forState:UIControlStateSelected];

回答2:

yd-tabbar
有一个 active-color 属性 参数对应类型为String
大概的意思就是 active-color="颜色" 高亮就会改变对应颜色