@implementation BSTabBarController + (void)load{ UITabBarItem *item = [UITabBarItem appearanceWhenContainedInInstancesOfClasses:@[self]]; NSMutableDictionary *textAttributes = [NSMutableDictionary dictionary]; [textAttributes setValue:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName]; [item setTitleTextAttributes:textAttributes forState:UIControlStateNormal]; [textAttributes setValue:[UIColor blackColor] forKey:NSForegroundColorAttributeName]; [item setTitleTextAttributes:textAttributes forState:UIControlStateSelected]; }
一个tabBarController有好几个tabBarItem, 一次性地设置外观很方便。