您的位置:首页 > 产品设计 > UI/UE

自定义UITabbarItem的title字体颜色

2016-04-27 17:25 567 查看
/* You may specify the font, text color, and shadow properties for the title in the text attributes dictionary, using the keys found in NSAttributedString.h.

中文大意:您可以指定字体、文本颜色和阴影属性的标题文本属性字典,使用钥匙NSAttributedString.h中找到。

*/

- (void)setTitleTextAttributes:(nullable
NSDictionary<NSString *,id> *)attributes forState:(UIControlState)state
NS_AVAILABLE_IOS(5_0)
UI_APPEARANCE_SELECTOR;

将下面代码直接拷贝到工程即可设定标签字体颜色

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];

UIColor *titleHighlightedColor = [UIColor getColor:@"05a2ea"];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
titleHighlightedColor, NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: