0

In my ios app, I always have a thin black line between my NavBar and/or TabBar and my underlying view. I tried to fix this by adjusting the thickness of the bars' borders to zero or setting the color of the bars' borders to the bar's color. None of this helped.

For example, I am able to adjust the thickness of the border of my UITabBar and UINavigationBar like so:

[nav1.navigationBar.layer setBorderWidth:5.0];
[navJudge.navigationBar.layer setBorderWidth:5.0];
[nav.tabBar.layer setBorderWidth:5.0];

On the other hand, setting the width to 0 does not remove the thin black line that separates my NavBar and TabBar from my view.

Since setting thickness to zero didn't work, I tried changing the border color:

[nav1.navigationBar.layer setBorderColor: [UIColor colorWithRed:0.216 green:0.263 blue:0.306 alpha:1].CGColor];
[navJudge.navigationBar.layer setBorderColor: [UIColor colorWithRed:0.216 green:0.263 blue:0.306 alpha:1].CGColor];
[nav.tabBar.layer setBorderColor:[UIColor colorWithRed:0.216 green:0.263 blue:0.306 alpha:1].CGColor];

This also works generally but when I set it to the shared background color of my view plus my NavBar and TabBar background colors (they're all the same), there is still a thin black line between the bars and the view.

Also the UIApplication window background color has been set to the same color as that of the UIView, the TabBar, and the NavBar. Still there is a black line. How can I fix this?

Thanks in advance for comments and answers.

  • Maybe you can upload your APP's photo – Zigii Wong Dec 03 '14 at 02:30
  • The answer to your question lies [here...](http://stackoverflow.com/questions/19226965/how-to-hide-ios7-uinavigationbar-1px-bottom-line) – MendyK Dec 03 '14 at 03:19
  • A follow-up: Most of the answers here: http://stackoverflow.com/questions/27261557/remove-thin-line-between-ui-nav-tab-bars-and-view did not work. The one that did work was the simplest, setting the clipsToBounds property of the TabBar and NavigationBar. I don't know why the shadowImage technique did not work for me. – Sunnyside Productions Dec 03 '14 at 03:35
  • Following up: the only method from @NewEngland's recommended post that worked was setting clipsToBounds for the NavigationBar and TabBar. I don't know why the shadowImage method did not work. – Sunnyside Productions Dec 03 '14 at 03:38

2 Answers2

1

This may work.

- (void)viewDidLoad
{
self.tabBar.layer.masksToBounds=YES;
self.tabBar.layer.borderWidth = 0.0;
self.tabBar.layer.borderColor = [UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:0].CGColor;
self.tabBar.layer.shadowColor =[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:0].CGColor;
self.tabBar.backgroundColor = [UIColor whiteColor];
}

The same as NavigationBar.

Zigii Wong
  • 7,766
  • 8
  • 51
  • 79
  • This does correct the 1 pixel line *but* it then leaves me with a black rectangle where the statusBar is normally presented. This is particularly ugly because the battery icon nonetheless remains. Any suggestions for a fix to that? – Sunnyside Productions Dec 03 '14 at 05:16
  • @SunnysideProductions I got the problem. Fixing. – Zigii Wong Dec 03 '14 at 05:55
  • @SunnysideProductions add `self.view.backgroundColor = [UIColor whiteColor]` or replace the color you wanted. – Zigii Wong Dec 03 '14 at 05:59
0

If I understand you correctly you need to do the following:

[UINavigationBar appearance].shadowImage = [[UIImage alloc] init];

This would remove standard shadow (which you see as a thin line below any navigation bar) through-out your whole application.

sha
  • 17,824
  • 5
  • 63
  • 98