Remove Navigationbar's bottom border iOS7

Gnamm picture Gnamm · Sep 27, 2013 · Viewed 23.3k times · Source

Is there a way to delete the bottom border that iOS7 automatically displays under the navigationbar?

Answer

wolffan picture wolffan · Dec 19, 2013

That does not work on iOS7 with navigation translucent or not...

A paste from Apple documentation;

Description The shadow image to be used for the navigation bar. The default value is nil, which corresponds to the default shadow image. When non-nil, this property represents a custom shadow image to show instead of the default. For a custom shadow image to be shown, a custom background image must also be set with the setBackgroundImage:forBarMetrics: method. If the default background image is used, then the default shadow image will be used regardless of the value of this property.

So basically you need to implement that setBackgroundImage. Additional note, on iOS7 you won't use appearance anymore but you'll modify the Navigation bar in the viewController context where you are now.

That is:

    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];

In my case I put this in viewDidLoad (custom behavior can be added for each UIViewController in the UINavigationViewController).