1

I am trying to assign a 60x60 px image to the tabBarItem.image:

self.tabBarItem.image = [UIImage imageNamed:@"tab_settings@2x.png"];

I have read in HIG, that I should put 60x60 px image for the Retina display. But what I get is an incorrectly sized image:

enter image description here

If I make it 30x30px ,it looks bad too (not like for Retina).

Nate
  • 31,017
  • 13
  • 83
  • 207
Denis Kutlubaev
  • 15,320
  • 6
  • 84
  • 70

1 Answers1

5

You don't need to specify that the @2x.png image is used. For your project, just add these two images in Xcode:

tab_settings@2x.png (60x60 pixels)

tab_settings.png (30x30 pixels)

And then in your code use this:

self.tabBarItem.image = [UIImage imageNamed:@"tab_settings"];

iOS will determine whether to use the 30x30, or 60x60 image for you. It's a really nice design by Apple.

Nate
  • 31,017
  • 13
  • 83
  • 207
  • I know it, it doesn't help in this situation. – Denis Kutlubaev Aug 28 '12 at 21:45
  • @wzbozon, that's the way to provide tab bar icons. Please double-check the sizes on both versions of your image. And don't use the string `"tab_settings@2x.png"` in your code. You should never, ever specify an image name with `"@2x"` in it, *in the code*. – Nate Aug 28 '12 at 21:47
  • yes, I checked and it started to work. Looks like there should be both images for Retina and not Retina. I was putting only for Retina. – Denis Kutlubaev Aug 28 '12 at 21:49