Is there a way to use a custom selected image for UITabBarItem?

前端 未结 9 1941
滥情空心
滥情空心 2020-12-08 05:52

I like to have a custom selected image when a user selects an item on the tab bar, by default it selects as blue like but would like to have a green color instead. something

相关标签:
9条回答
  • 2020-12-08 06:43

    For iOS5 and upwards, you can just do this:

    rootTabBarController.tabBar.selectedImageTintColor = [UIColor greenColor];
    
    0 讨论(0)
  • 2020-12-08 06:44

    In AppDelegate.m

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions (NSDictionary *)launchOptions {
    
    [[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]]; 
    
    return YES;
    
    }
    

    This will give you a red color, change the color with the one you wish whiteColor, blueColor etc..

    0 讨论(0)
  • 2020-12-08 06:45

    When using storyboards you can simply select your TabBarController's TabBar and then change the Image Tint in the Identity Inspector. This should also work with XIBs.

    Look here for an image describing the todos

    0 讨论(0)
提交回复
热议问题