I ran into the same issue and none of the answers were truly satisfying. Here is my take for Swift3:
func hideNavigationBarLine() {
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
}
Simply call this from within viewDidLoad().