我想将我的 DocumentPicker 的导航栏背景颜色设置为与我的应用程序的其余部分相同。
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)
不起作用。
我尝试过的其他事情:
使用 UINavigationBar.appearance().backgroundColor = self.theme.navigationBarColor
- 不起作用,看起来更像是一种变通方法,而不是正确的方法。
编辑: 现在我们的应用程序被重新设计为使用原色作为导航栏文本颜色,并具有与 DocumentPicker 相同的背景颜色。答案仍将不胜感激。
最佳答案
这将改变文本的颜色,例如“取消”。
UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.blue], for: .normal)
这将改变箭头的颜色。
UIButton.appearance().tintColor = UIColor.blue
如果需要,请不要忘记在关闭选择器后将其设置回原来的颜色。
关于ios - UIDocumentPickerViewController - 如何设置导航栏颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46316961/