How to disable UINavigationBar shadow in iOS 9 (Swift)

Alexander Deplov
Simple Swift programming tips
2 min readJul 21, 2015


Easiest way to remove UINavigationBar bottom 1px border.

This trick can be applied to iOS 8 and iOS 7. The UINavigationBar bottom border is an 1px shadow. According to the documentation to remove it you have to provide UIImage. But we’re going to create an empty UIImage.

In viewDidAppear:

override func viewDidAppear(animated: Bool) {

let img = UIImage()

self.navigationController?.navigationBar.shadowImage = img

self.navigationController?.navigationBar.setBackgroundImage(img, forBarMetrics: UIBarMetrics.Default)



If you want to change background color to the navigationBar, do this:


This technique was used in our new version (currently in development) of Anchor Pointer app: GPS compass for iPhone.

UINavigationBar in Anchor Pointer