// 通过appearance统一设置UITabBarItem的文字属性
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
selectedAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
// 拿到UITabBarItem的appearance
UITabBarItem *item = [UITabBarItem appearance];
[item setTitleTextAttributes:attrs forState:UIControlStateNormal];
[item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];通过appearance统一设置UITabBarItem的文字属性
最新推荐文章于 2022-11-30 17:54:25 发布
本文介绍如何使用appearance API来统一设置iOS应用中UITabBarItem的文字属性,包括未选中和选中状态下的字体大小及颜色。
9935

被折叠的 条评论
为什么被折叠?



