UIDocumentPickerViewController - 如何设置导航栏颜色

问题描述 投票:10回答:1

我想将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相同的背景颜色。答案仍将受到赞赏。

ios swift uidocumentpickervc
1个回答
2
投票

这将改变文本的颜色,如“取消”。

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

这将改变箭头的颜色。

UIButton.appearance().tintColor = UIColor.blue

如果需要,请关闭拾取器后,不要忘记将其恢复为原始颜色。

© www.soinside.com 2019 - 2024. All rights reserved.