利用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];
}

 

posted @ 2016-06-14 16:36  Oooliver  阅读(306)  评论(0编辑  收藏  举报
为用户提供更好的解决方案,技术改变世界