Reputation: 1243
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.
_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.
Upvotes: 1
Views: 335
Reputation: 38239
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
.
Upvotes: 1