Reputation: 1380
I have created UITabBarController programatically with 5 tabs like,
UIViewController *profileVC = [[UIViewController alloc] init];
UINavigationController *profileNC=[[UINavigationController alloc]initWithRootViewController:profileVC];
UIImage *profileImage = getImage(@"tab1", NO);
UIImage *profileImageSel = getImage(@"tab1_s", NO);
profileImage = [profileImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
profileImageSel = [profileImageSel imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
profileNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:profileImage selectedImage:profileImageSel];
... etc.
UITabBarController *tabBarVC = [[UITabBarController alloc]init];
tabBarVC.tabBar.backgroundColor = [UIColor whiteColor];
[tabBarVC setViewControllers:@[profileNC,...]];
tabBarVC.view.autoresizingMask=(UIViewAutoresizingFlexibleHeight);
[self.navigationController presentViewController:tabBarVC animated:YES completion:^{
}];
But its displaying the line at the top and having the space at the bottom
How to fix this issue? pls help.
Upvotes: 0
Views: 1843
Reputation: 596
try this, hope it can work for you.
viewController.navigationController.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -12);
Upvotes: 0
Reputation: 1297
Check the size of your images, they might be smaller than the hight of the tab bar.
To remove the top and bottom lines you can try something like this in the viewDidLoad:
method:
self.tabBar.backgroundImage = [UIImage new];
[[UITabBar appearance] setShadowImage:[UIImage new]];
I am assuming the lines you see are really the original background of the tab bar, which is a semi-transparent background, if you use bigger images, they should fill up all the bar but you might still see a small border line at the top, with the code above you can remove any background and especially the top line.
Upvotes: 1