UIDocumentPickerViewController导航栏按钮颜色

Kry*_*těj 11 uinavigationbar ios ios11

我的应用程序使用带有白色按钮和文本的红色导航栏(2)栏.当我使用系统联系人选择器(3)时,状态栏为红色.当我使用文件选择器(1)时,UIDocumentPickerViewController导航栏是白色的.如何更改导航栏或文本的颜色?

当我使用下面的代码时,它可以工作,但它也改变了我的导航栏.

UINavigationBar.appearance().tintColor = .red
Run Code Online (Sandbox Code Playgroud)

感谢帮助

码:

func open() {
        UINavigationBar.appearance().barTintColor = .green
        let documentsController = UIDocumentPickerViewController(documentTypes: makeDocumentTypesList(), in: .import)
        documentsController.delegate = self
        viewControllerProvider.getViewController().present(documentsController, animated: true, completion: nil)
    }
Run Code Online (Sandbox Code Playgroud)

导航栏

Ant*_*amy 25

您只需UIDocumentPickerViewController将此代码放在application:didFinishLaunchingWithOptions:函数中的某个位置即可重置外观,条形按钮将恢复为原始蓝色,或者您可以设置您选择的任何其他颜色.另一方面,条形颜色不可定制.

if #available(iOS 11.0, *) {
    UINavigationBar.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self]).tintColor = nil
}
Run Code Online (Sandbox Code Playgroud)