UITabBar属性的设置

这些内容通常写在+initialize方法里

//首先拿到UITabBar
UITabBar * tab = [UITabBar appearance];
//背景颜色
//tab.barTintColor = [UIColor yellowColor];
//前景颜色
//tab.tintColor = [UIColor orangeColor];
//设置背景图片
[tab setBackgroundImage:[UIImage imageNamed:@"tabbar"]];
//设置透明度
tab.alpha = 0.3;
// UIControlStateNormal状态下的文字属性
 NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
//文字颜色
dictionary[NSForegroundColorAttributeName] = [UIColor blackColor];
//文字大小
dictionary[NSFontAttributeName] = [UIFont systemFontOfSize:12];

// UIControlStateSelected状态下的文字属性
NSMutableDictionary * seleDictionary = [NSMutableDictionary dictionary];
seleDictionary[NSForegroundColorAttributeName] = [UIColor colorWithRed:255 / 256.0 green:255 / 256.0  blue:130 / 256.0 alpha:1];

UITabBarItem * itme = [UITabBarItem appearance];
[itme setTitleTextAttributes:dictionary forState:UIControlStateNormal];
[itme setTitleTextAttributes:seleDictionary forState:UIControlStateSelected];
//每一个控制器都有tabBarItem这个属性
childController.tabBarItem.image = [UIImage imageNamed:image];
childController.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];
childController.tabBarItem.badgeValue = @"11";
//设置消息标题的字体大小
[item setBadgeTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:25]} forState:UIControlStateNormal];

你可能感兴趣的:(UITabBar属性的设置)