UINavigationBar.appearance().shadowImage = UIImage() 在 swift 4

UINavigationBar.appearance().shadowImage = UIImage() in swift 4

如何在 swift 4 或 xcode 9 中实现此代码?

// Remove hairline between navigation bar and anything below such as search bar
UINavigationBar.appearance().shadowImage = UIImage()

我想删除导航栏下划线。

请检查:

self.navigationController?.navigationBar.shadowImage = UIImage()

不用担心复制粘贴会起作用。

// Remove Bottom Shadow
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)