How to change the background color and text color of done button? Is there a way that I can change the navigationbar color and navigation bar title color and bottom bar color also? Attached screenshot for reference:
如何更改完成按钮的背景颜色和文本颜色?有没有办法可以更改导航栏颜色和导航栏标题颜色和底栏颜色?附上截图供参考:
6 个解决方案
#1
1
I solved it. Here is the code working for me perfectly:
我解决了这是完美地为我工作的代码:
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
UINavigationBar.appearance().barTintColor = Colors.redColor()
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 14, weight: UIFontWeightBold)]
return self
}
#2
1
It's a little hacky as its relying on the fact that QLPreviewController is the class implementing the UIDocumentInteractionController but something like this is the least intrusive solution. Do it before you display the UIDocumentInteractionController
它有点hacky因为它依赖于QLPreviewController是实现UIDocumentInteractionController的类,但是这样的东西是最不具侵入性的解决方案。在显示UIDocumentInteractionController之前执行此操作
import QuickLook
UIBarButtonItem.appearance(whenContainedInInstancesOf [QLPreviewController.self]).tintColor = UIColor.black
#3
0
I have a idear to change the bar color:
我有改变条形颜色的想法:
let allNavigationBar = UINavigationBar.appearance()
allNavigationBar.barTintColor = UIColor.red // change the bar background color
allNavigationBar.tintColor = UIColor.black // change the Done button's tintColor
let alloolbar = UIToolbar.appearance()
allToolbar.barTintColor = UIColor.red // dones't work, try backgroundImage
allToolbar.backgroundColor = UIColor.blue // dones't work
allToolbar.tintColor = UIColor.brown // change the toolbar's item tint color
but this method has a great effect,all your UINavigationBar
and UIToolBar
will make that change.
但是这个方法效果很好,所有你的UINavigationBarand UIToolBar都会做出改变。
Hope anyone else can give a better solusion.
希望其他人能给出更好的解决方案。
#4
0
You can change the tint color of the window temporally.
您可以暂时更改窗口的色调颜色。
func presentDocument() {
//present the controller here
self.appDelegate.window.tintColor = UIColor.red
}
Then change it back later:
然后再改回来:
func documentInteractionControllerDidEndPreview(documentInteractionController) { //replace parameter with your uidocumentviewinteractioncontroller
self.appDelegate.window.tintColor = UIColor.white
}
#5
0
@Dee. I guess you have asked this part in one of your other question. In that case you were not able to show that preview controller. In that question suggested answer is to return "self" from that delegate method. If you implement that correctly then your preview will use same navigation bar colour as its parent controller is using. I mean if you have opened UIDocumentInteractionController directly from some ViewController then UIDocumentInteractionController will use its parent viewController's navigation bar colour. This may help you to change Done button colour
@Dee。我想你在另一个问题中已经问过这部分了。在这种情况下,您无法显示预览控制器。在那个问题中,建议的答案是从该委托方法返回“self”。如果您正确实现,那么您的预览将使用与其父控制器使用相同的导航栏颜色。我的意思是如果您直接从某些ViewController打开了UIDocumentInteractionController,那么UIDocumentInteractionController将使用其父viewController的导航栏颜色。这可以帮助您更改完成按钮颜色
#6
-1
let QLNavAppearance = UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self])
QLNavAppearance.tintColor = UIColor.red // some
QLNavAppearance.barTintColor = UIColor.red // some
QLNavAppearance.backgroundColor = UIColor.red // some
#1
1
I solved it. Here is the code working for me perfectly:
我解决了这是完美地为我工作的代码:
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
UINavigationBar.appearance().barTintColor = Colors.redColor()
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 14, weight: UIFontWeightBold)]
return self
}
#2
1
It's a little hacky as its relying on the fact that QLPreviewController is the class implementing the UIDocumentInteractionController but something like this is the least intrusive solution. Do it before you display the UIDocumentInteractionController
它有点hacky因为它依赖于QLPreviewController是实现UIDocumentInteractionController的类,但是这样的东西是最不具侵入性的解决方案。在显示UIDocumentInteractionController之前执行此操作
import QuickLook
UIBarButtonItem.appearance(whenContainedInInstancesOf [QLPreviewController.self]).tintColor = UIColor.black
#3
0
I have a idear to change the bar color:
我有改变条形颜色的想法:
let allNavigationBar = UINavigationBar.appearance()
allNavigationBar.barTintColor = UIColor.red // change the bar background color
allNavigationBar.tintColor = UIColor.black // change the Done button's tintColor
let alloolbar = UIToolbar.appearance()
allToolbar.barTintColor = UIColor.red // dones't work, try backgroundImage
allToolbar.backgroundColor = UIColor.blue // dones't work
allToolbar.tintColor = UIColor.brown // change the toolbar's item tint color
but this method has a great effect,all your UINavigationBar
and UIToolBar
will make that change.
但是这个方法效果很好,所有你的UINavigationBarand UIToolBar都会做出改变。
Hope anyone else can give a better solusion.
希望其他人能给出更好的解决方案。
#4
0
You can change the tint color of the window temporally.
您可以暂时更改窗口的色调颜色。
func presentDocument() {
//present the controller here
self.appDelegate.window.tintColor = UIColor.red
}
Then change it back later:
然后再改回来:
func documentInteractionControllerDidEndPreview(documentInteractionController) { //replace parameter with your uidocumentviewinteractioncontroller
self.appDelegate.window.tintColor = UIColor.white
}
#5
0
@Dee. I guess you have asked this part in one of your other question. In that case you were not able to show that preview controller. In that question suggested answer is to return "self" from that delegate method. If you implement that correctly then your preview will use same navigation bar colour as its parent controller is using. I mean if you have opened UIDocumentInteractionController directly from some ViewController then UIDocumentInteractionController will use its parent viewController's navigation bar colour. This may help you to change Done button colour
@Dee。我想你在另一个问题中已经问过这部分了。在这种情况下,您无法显示预览控制器。在那个问题中,建议的答案是从该委托方法返回“self”。如果您正确实现,那么您的预览将使用与其父控制器使用相同的导航栏颜色。我的意思是如果您直接从某些ViewController打开了UIDocumentInteractionController,那么UIDocumentInteractionController将使用其父viewController的导航栏颜色。这可以帮助您更改完成按钮颜色
#6
-1
let QLNavAppearance = UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self])
QLNavAppearance.tintColor = UIColor.red // some
QLNavAppearance.barTintColor = UIColor.red // some
QLNavAppearance.backgroundColor = UIColor.red // some