// 通过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 发布