5

I have included the need for a navbar (navigationController) with the same tint of the background of the bar viewController ... Now I have a problem ... Between the navbar and the view I have a horizontal line that separates them, as you can see from the picture .. Can you tell me how can I delete this line horizontal black and make it more consistent?

I tried this in AppDelegate:

[[UINavigationBar appearance] setShadowImage: [[UIImage alloc] init]];

     UINavigationController * nav = (UINavigationController *) self.window.rootViewController; nav.navigationBar.translucent = NO;

But I did not get results. Can you help? Thanks to all of Rory.

enter image description here

kAiN
  • 2,559
  • 1
  • 26
  • 54

2 Answers2

13

You also have to set background image for navigation bar in order to achieve your requirement

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
Yuvrajsinh
  • 4,536
  • 1
  • 18
  • 32
  • Great, this makes things much more 'easy going to change the AppDelegate! Thank you very much! – kAiN Oct 15 '13 at 13:53
  • Its not working work me. I tried by writing this code in Appdelegate as well as in my viewController also. I did'nt get it. Why its not working. – iDevAmit Feb 14 '14 at 06:41
  • @ErAmitSachdeva I think you are also doing some another tricks also on Navigation bar. Otherwise it's working. – Yuvrajsinh Feb 14 '14 at 07:52
3

You can hide it by using following code :

UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 43, 320, 1)];
[overlayView setBackgroundColor:[UIColor whiteColor]];
[navBar addSubview:overlayView]; // navBar is your UINavigationBar instance
[overlayView release];

Here is Ref : How to remove UINavigatonItem's border line

Community
  • 1
  • 1
Divya Bhaloidiya
  • 5,018
  • 2
  • 25
  • 45
  • Divya works perfectly ... In a nutshell you create a view and soprappone the navbar right? All this should not even be "negative" in the eyes of the guidelines of apple right? However Correct answer +1 – kAiN Oct 15 '13 at 13:44