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]];
Share:
15,694

Related videos on Youtube

Jesper Martensson
Author by

Jesper Martensson

Updated on June 07, 2022

Comments

  • Jesper Martensson
    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

    enter image description here

    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]];
    
  • iccir
    iccir almost 11 years
    Setting shadowImage to a clear image should get rid of it, provided that you also have a backgroundImage set
  • Raptor
    Raptor about 10 years
    This code is confusing. The variable name is tabBar but you initialize UITabBarController on it.
  • Raptor
    Raptor about 10 years
    Note: 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 transparent UIImage.
  • Raptor
    Raptor about 10 years
    My suggestion: rename the variable to tabBarController to avoid confusion
  • dineshthamburu
    dineshthamburu about 10 years
    tabBar 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
    Raheel Sadiq over 8 years
    Well it doesn't remove it, but make it white, I have a big center button and it cutting right though it
  • DawnSong
    DawnSong over 8 years
    Private API is not preferred.
  • DawnSong
    DawnSong over 8 years
    @Raptor You are a genius.