iOS: 导航顶部栏和 UIviewController 的其他内容之间的线

iOS: Line between navigation top bar and other contents of UIviewController

我用 Swift 3 和 Xcode 8.1 创建了一个应用程序,我有一个带导航栏的视图控制器,我的视图在导航栏和其他 viewController的内容。

我在 viewDidLoad 中使用了以下代码:

 self.navigationController?.navigationBar.isTranslucent = false 

但没有任何变化,有关更多详细信息,请查看屏幕截图:

我能做些什么来解决这个问题?

尝试:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()

如果你想将这个效果应用到整个应用程序(这样你就不需要为每个导航控制器编写这段代码)你可以使用:

UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarPosition: UIBarPosition.Any, barMetrics: UIBarMetrics.Default)
UINavigationBar.appearance().shadowImage = UIImage()