0

Is there an easy way to set the background color of an individual UITabBarItem?

In my scenario, I would like to use a different image for each of my 2 barItems and then set the background of my 2 barItems to a different background color each- say red and green.

I am not looking to set the background color of the whole tabBar.

Khaled Barazi
  • 8,681
  • 6
  • 42
  • 62

2 Answers2

0

You need to set selected and unselected image.

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"img"] withFinishedUnselectedImage:[UIImage imageNamed:@"img"]];
BoilingLime
  • 2,207
  • 3
  • 22
  • 37
  • Are you assuming that the images will have the colored background? My question was about getting an image (asset) with no background. And then after adding the image, adding a colored background to the section behind that image in the Tabbar. – Khaled Barazi Oct 08 '14 at 16:02
0

I think that following is easy.

  • To use a big separated background image.
  • To superpose image and background color. (using UIGraphics)
Daishi Nakajima
  • 1,932
  • 18
  • 26