透明导航栏(swift 3)

Rea*_*asy 1 uinavigationbar ios swift swift3

我做了以下操作,使导航栏只是白色.

UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
Run Code Online (Sandbox Code Playgroud)

所以我将每个UIViewController设置为"not under top/bot bar".这看起来像我想要的.但是当我制作一个UIImagePicker时,它看起来像这样: 导航栏

所以我尝试了以下方法:

let imagePicker = UIImagePicker()
imagePicker.edgesForExtendedLayout = []
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我该怎么做?

请注意!

Fon*_*nix 8

导航栏默认为白色吗?好像

UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
Run Code Online (Sandbox Code Playgroud)

将背景设置为没有数据的图像,因此它将是透明的.如果您确实需要设置导航栏的颜色,请使用

UINavigationBar.appearance().barTintColor = UIColor.white
Run Code Online (Sandbox Code Playgroud)

而不是将背景设置为图像.你可能需要

self.navigationController!.navigationBar.isTranslucent = false
Run Code Online (Sandbox Code Playgroud)

在每个viewController的viewDidLoad中,但首先尝试不使用它