Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prat14k/8c8e616d6b732cf03ac22f4d8bcdc32e to your computer and use it in GitHub Desktop.
Save prat14k/8c8e616d6b732cf03ac22f4d8bcdc32e to your computer and use it in GitHub Desktop.
remove 1px bottom line of the navigation bar

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment