利用UI_APPEARANCE统一设置UITabBarItem样式

-(void)setupTabBarItemAttributes{
    
    //attributes
    NSMutableDictionary *selectedAttrs= [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:10];//label字体大小
    selectedAttrs[NSForegroundColorAttributeName] = [UIColor orangeColor];//选中字体颜色
    NSMutableDictionary *attrs= [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = selectedAttrs[NSFontAttributeName];
    attrs[NSForegroundColorAttributeName] = [UIColor lightGrayColor];//未选中字体颜色
    
    UITabBarItem *item=[UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
}

 

转载于:https://www.cnblogs.com/oshushu/p/5584521.html

你可能感兴趣的:(利用UI_APPEARANCE统一设置UITabBarItem样式)