appearance

通过appearance统一设置所有UITabBarItem的文字属性
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
attrs[NSForegroundColorAttributeName] = [UIColor grayColor];

NSMutableDictionary *selectAttrs = [NSMutableDictionary dictionary];
selectAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
selectAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];

UITabBarItem *item = [UITabBarItem appearance];
[item setTitleTextAttributes:attrs forState:UIControlStateNormal];
[item setTitleTextAttributes:selectAttrs forState:UIControlStateSelected];

后面带有UI_APPEARANCE_SELECTOR的方法,都可以通过appearance对象来统一设置

你可能感兴趣的:(appearance)