UIDocumentPickerViewController - setting the color of the navigation bar

I want the background color of the navigation bar of my DocumentPicker to be the same as the rest of my application.

let filePicker = UIDocumentPickerViewController(documentTypes: ["public.content"], in: .import) filePicker.delegate = self filePicker.navigationController?.navigationBar.barTintColor = self.theme.navigationBarColor self.present(filePicker, animated: true, completion: nil) 

does not work.

Other things I've tried:

Use UINavigationBar.appearance().backgroundColor = self.theme.navigationBarColor - does not work and is too similar to a workaround, and not to the correct path if it works.

Edit: Now our application has been redesigned to use the foreground color as the text color in the navigation bar and have the same background color as the DocumentPicker. Replies will still be appreciated.

+9
ios swift
source share
2 answers

This will change the color of the text, such as Cancel.

 UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.blue], for: .normal) 

and that will change the color of the back arrow.

 UIButton.appearance().tintColor = UIColor.blue 

Remember to return it to its original colors after closing the picker, if necessary.

+2
source share

I just did everything that was offered in StackOverflow related to the problem, but nothing solved the problem. Then I made only one simple change, and that just solved it. Instead of presenting a UIDocumentPickerViewController , I just showed it and it was the same color as my application.

do it:

 self.show(filePicker, sender: nil) 
0
source share

All Articles