Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom UITabBarItem without title label

I am trying to create a UITabBar that I will customize using the appearance API. I am stuck on trying to remove the title label from the UITabBarItem and resizing the image to make it centered. If you just delete the title text, there will be empty space below the image and the bottom of the bar.

Does anyone know how to make a UITabBarItem without a title?

like image 594
mrosales Avatar asked Oct 07 '12 17:10

mrosales


1 Answers

Set the title to nil and move the icon

self.tabBarItem = [[UITabBarItem alloc] initWithTitle:nil
                                                image:[[UIImage imageNamed:@"icon_tabbar_inactive.png"]
                                                    imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
                                        selectedImage:[[UIImage imageNamed:@"icon_tabbar_active.png"]
                                                    imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

// Move the tabbar icon to the middle of tabbar
self.tabBarItem.imageInsets = UIEdgeInsetsMake(6.0, 0.0, -6.0, 0.0);
like image 162
carmen Avatar answered Sep 23 '22 19:09

carmen