If you just want to use a solid navigation bar color and have set this up in your storyboard, use this code in your
AppDelegate
class to remove the 1 pixel border via the appearance proxy:
Objective-C
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
forBarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
Swift 3.x
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
NOTE: must set isTransluscent
UINavigationBar instance to false
to avoid transparent navigation bar; either in storyboard or in code
navigationController?.navigationBar.isTranslucent = false
// or
navigationBar.isTranslucent = false
iOS 15:
Note: If you have any scrollable content (scroll view, table view) in your view controller beware of the new behaviour which comes with
scrollEdgeAppearance
introduced in iOS 15. This appearance by default produces a transparent background, to all navigation bars. The background is controlled by when your scroll view scrolls content behind the navigation bar.To avoid having transparent nav bars on your screens and still be able to remove the bottom line, use: