在 QLPreviewController 中更改导航栏颜色

Rus*_*abh 3 iphone xcode ios swift3 ios11

我想在 swift 3 中更改 QLPreviewController 的导航栏颜色。我使用下面的代码来更改颜色但它不起作用

viewQLPreview = QLPreviewController()
viewQLPreview.dataSource = self
viewQLPreview.delegate = self
viewQLPreview.navigationController?.navigationBar.isTranslucent = false
viewQLPreview.navigationController?.navigationBar.tintColor = UIColor.red
Run Code Online (Sandbox Code Playgroud)

Rus*_*abh 6

我使用以下代码在 swift 3.0 中更改 QLPreviewController 的导航栏颜色

UINavigationBar.appearance().barTintColor = UIColor.red

UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).backgroundColor = UIColor.red
Run Code Online (Sandbox Code Playgroud)