Horizontal Separator NavBar IOS 7

2020-05-28 11:13发布

问题:

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.

回答1:

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]];


回答2:

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