Search code examples
iosobjective-cuitabbarcontrolleruicoloruitabbaritem

colour icon in UITabbar item objective-c


I have a UITabbar controller with 3 item, I want to have colour icon instead of based Gary icons,

would you please give me some hint that how can I have colour icon in tababr,

Here is my code:

self.title = @"test";

   self.tabBarItem = [[UITabBarItem alloc] initWithTitle:self.title image:[UIImage 
 imageNamed:@"test"] tag:0];

normally test is a icone with a colour picture, but in UITabbar it's just Gary,

Thanks in advance!


Solution

  • Use this code:

    [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"test"] 
    withFinishedUnselectedImage:[UIImage imageNamed:@"test"]];