How to remove space under UITabBarItem?

I created a tabBar and set the image in it, but it leaves too much space below the tabBarItem . How can i remove this?

This is my tabBar than display now

enter image description here

And I want to display it like this

enter image description here

To display a tab

 firstVC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil]; secondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; thirdVC = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil]; forthVC = [[ForthViewController alloc] initWithNibName:@"ForthViewController" bundle:nil]; [[UITabBar appearance] setTintColor:[UIColor whiteColor]]; NSArray *viewControllersArray = [[NSArray alloc] initWithObjects:firstVC,secondVC,thirdVC,forthVC, nil]; self.tabController = [[UITabBarController alloc] init]; [self.tabController setViewControllers:viewControllersArray animated:NO]; [self.window addSubview:self.tabController.view]; //self.tabController.selectedIndex = 1; self.tabController.delegate = self; self.window.rootViewController = self.tabController; [self.window makeKeyAndVisible]; 

For the tabBar background image, I used this code

 UIImage* tabBarBackground = [UIImage imageNamed:@"tabbarimg1.png"]; [[UITabBar appearance] setBackgroundImage:tabBarBackground]; 

And for setting imge in the element I used this code

 //used to set the tabBarItem images [self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"home_tab"] withFinishedUnselectedImage:[UIImage imageNamed:@"home_tab"]]; //Set the badge on tabBarItem [self.tabBarItem setBadgeValue:@"15"]; 
+8
ios iphone uitabbaritem tabbar
source share
2 answers

As Vytis says in their answer here :

UIBarItem has a property (the UIBarButton element inherits from this class) imageInsets .

To use images with full height (49 pixels) for finishedSelectedImage and finishedUnselectedImage you need to set these image inserts:

tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

you need to write the following lines of code

 item0.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0); item1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0); item2.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0); item2.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0); 
+17
source share

I think you should use the image image in xib for this, e.g. enter image description here

for your requirement top should be some kind of positive value, and the bottom should be some kind of negative value. If you added the tab bar programmatically, you can send a response to Wills

+9
source share

All Articles