iOS 7 tabBar-line, how to remove it?
15,694
Solution 1
UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar_bg.png"];
[[UITabBar appearance] setShadowImage:tabBarBackground];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
Solution 2
These code works pretty well for me (I don't really have background image for tab bar):
[tab_main.tabBar setBackgroundImage:[[UIImage alloc] init]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
And I use these code to add a frame too:
UIColor* color_green = UIColorFromRGB(0x348e5b);
tab_main.tabBar.layer.borderWidth = 0.50;
tab_main.tabBar.layer.borderColor = color_green.CGColor;
[[UITabBar appearance] setTintColor:color_green];
Hope that helps.
Solution 3
In iOS 8 the top border can be removed by setting the tab bar style to black in the inspector.
Solution 4
Swift
Nice simple solution:
Write this below code in your custom tab bar class. Then it will hide horizontal shadow line.
self.tabBar.setValue(true, forKey: "_hidesShadow")
Objective C
[self.tabBar setValue:@(YES) forKeyPath:@"_hidesShadow"];
Solution 5
self.tabBarController = [[UITabBarController alloc] init];
[[[self tabBarController] tabBar] setBackgroundImage:[UIImage imageNamed:@"YOURIMAGE.png"]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
Related videos on Youtube
Author by
Jesper Martensson
Updated on June 07, 2022Comments
-
Jesper Martensson about 2 years
Apple has added a tiny line over the tabBar in iOS 7 which is supposed to work as a shadow or fade between the tabBar and the UI
Since I am using a custom-made tabBar the line is quite irritating. How do you remove it? Please tell me it is possible, otherwise I need to redesign my whole app lol....
/ Regards
*Edit
Sloved my problem with the following line of code:
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
-
holex about 10 years
[_tabBar setClipsToBounds:TRUE];
-
Pradeep Mittal over 9 yearsholex answer worked like a miracle for me ^_^
-
QED over 8 yearsPossible duplicate of Remove UITabBar horizontal separator in iOS7
-
-
iccir almost 11 yearsSetting shadowImage to a clear image should get rid of it, provided that you also have a backgroundImage set
-
Raptor about 10 yearsThis code is confusing. The variable name is
tabBar
but you initializeUITabBarController
on it. -
Raptor about 10 yearsNote: If you
setShadowImage
, it will occupy some spaces above the Tab Bar Controller. It's better to use[[UITabBar appearance] setShadowImage:[[UIImage alloc] init];
to provide an empty and transparentUIImage
. -
Raptor about 10 yearsMy suggestion: rename the variable to
tabBarController
to avoid confusion -
dineshthamburu about 10 yearstabBar is object of UITabBarController.That means, @property (nonatomic, retain) UITabBarController* tabBar;I had edit the name tabBar to tabBarController(@property (nonatomic, retain) UITabBarController* tabBarController).Now you can understand the code without confusion.
-
Raheel Sadiq over 8 yearsWell it doesn't remove it, but make it white, I have a big center button and it cutting right though it
-
DawnSong over 8 yearsPrivate API is not preferred.
-
DawnSong over 8 years@Raptor You are a genius.