How to Disable UINavigationBar Shadow in iOS 9 Swift
·
Alexander Deplov
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) {
super.viewDidAppear(animated)
let img = UIImage()
navigationController?.navigationBar.shadowImage = img
navigationController?.navigationBar.setBackgroundImage(img, for: .default)
}
Result:
If you want to change background color to the navigationBar, do this:
Result:
This technique was used in our new version (currently in development) of Anchor Pointer: GPS compass for iPhone.