UIDocumentPickerViewController-如何设置导航栏颜色 [英] UIDocumentPickerViewController - How to set the navigation bar color

查看:634
本文介绍了UIDocumentPickerViewController-如何设置导航栏颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将DocumentPicker的导航栏背景颜色设置为与应用程序的其余部分相同.

I want to set the navigation bar background color 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)

不起作用.

我尝试过的其他事情:

使用UINavigationBar.appearance().backgroundColor = self.theme.navigationBarColor-不起作用,并且看起来像是一种替代方法,而不是一种可行的方法.

Use UINavigationBar.appearance().backgroundColor = self.theme.navigationBarColor - doesn't work and looks too much like a workaround instead of a proper way if it works.

现在,我们的应用已经过重新设计,可以使用原色作为导航栏文本颜色,并且具有与DocumentPicker相同的背景色.答案仍然会得到赞赏.

Right now our app is redesigned to use the primary color as navigation bar text color, and have the same background color as the DocumentPicker. Answers will still be appreciated.

推荐答案

这将更改文本的颜色,例如取消".

This will change the color of the text like "Cancel".

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

这将更改箭头的后退颜色.

and this will change the arrow back color.

UIButton.appearance().tintColor = UIColor.blue

如果需要,在关闭选择器后不要忘记将其恢复为原始颜色.

Don't forget to set it back to your original colors after closing the picker if it required.

这篇关于UIDocumentPickerViewController-如何设置导航栏颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆