To change the color of unselected UITabBar icon in iOS 7?

后端 未结 4 1181
小蘑菇
小蘑菇 2020-12-08 22:09

I know this question has been asked earlier as well, but still i didn\'t get any solution searching the solution on internet.

I referred the following posts:

4条回答
  •  感动是毒
    2020-12-08 22:31

    [[UITabBar appearance] setTintColor:[UIColor colorWithRed:252/255.0 green:218/255.0 blue:49/255.0 alpha:1.0]];
    
    tabBarItem1.image = [[UIImage imageNamed:@"home_icon.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        tabBarItem1.selectedImage = [UIImage imageNamed:@"home_icon_selected.png"];
    
    [[UITabBar appearance] setBackgroundColor:[UIColor colorWithRed:15/255.0 green:85/255.0 blue:160/255.0 alpha:1.0]];
        // Change the title color of tab bar items
        [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                           [UIColor whiteColor], NSForegroundColorAttributeName,
                                                           nil] forState:UIControlStateNormal];
        UIColor *titleHighlightedColor = [UIColor colorWithRed:252/255.0 green:218/255.0 blue:49/255.0 alpha:1.0];
        [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                           titleHighlightedColor, NSForegroundColorAttributeName,
                                                           nil] forState:UIControlStateHighlighted]
    

提交回复
热议问题