1

I have a UITabBar with 4 tabs. 3/4 tabs have a title and an image. I'd like to show only an image in the first tab. It works on simulator good, but on iPhone it looks like the screenshot. It crops at the bottom. Icon sizes: 46x42 for 2,3 and 4th icons (retina size), and 92x80 for the 1st icon for retina size.

The screenshot

enter image description here

The code

_tabBarController = [[UITabBarController alloc]init];
_tabBarController.delegate=self;

_firstNavigationController = [[TypeCollectionViewController alloc] initWithNibName:@"TypeCollectionViewController" bundle:nil];
_firstNavigationController.title = @"first";
firstNavigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
NSArray *controllers = [NSArray arrayWithObjects: firstNavigationController, secondNavigationController, thirdNavigationController, fNavigationController, nil];
_tabBarController.viewControllers = controllers;

[[[_tabBarController.tabBar items] objectAtIndex:0] setImage:[UIImage imageNamed:@"first-icon.png"]];
[[[_tabBarController.tabBar items] objectAtIndex:1] setImage:[UIImage imageNamed:@"second-icon.png"]];
[[[_tabBarController.tabBar items] objectAtIndex:2] setImage:[UIImage imageNamed:@"third-icon.png"]];
[[[_tabBarController.tabBar items] objectAtIndex:3] setImage:[UIImage imageNamed:@"f-icon.png"]];

[_tabBarController setSelectedIndex:0];

[self.window setRootViewController:_tabBarController];
[[[_tabBarController.tabBar items] objectAtIndex:0] setTitle:nil];
[self.window makeKeyAndVisible];

How to fix this issue? Thanks in advance.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Artem Z.
  • 1,243
  • 2
  • 14
  • 36

1 Answers1

1

Note : UITabbarItem's image size should be 32 pixel height. Follow Bars Guidleline.

Also also image provided should be with non-retina as well as retina image to tabbar item.

What i mean here if you think that only retina image can be used for tabbar then in non-retina device UI might be unexpected.

Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
  • No-no, I use 2 kinds of images. For retina and non-retina size for each icons. I know about bars guideline, but I have another application where I have big images in UITabBar. – Artem Z. Apr 28 '14 at 07:09