回答

0

我有一个IDEAR改变栏的颜色:

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 

但这种方法有很大的作用,所有的UINavigationBarUIToolBar将做出的改变。

希望其他人能给出更好的选择。

0

您可以暂时更改窗口的色调颜色。

func presentDocument() { 
    //present the controller here 
    self.appDelegate.window.tintColor = UIColor.red 
} 

再改回来以后:

func documentInteractionControllerDidEndPreview(documentInteractionController) { //replace parameter with your uidocumentviewinteractioncontroller 
    self.appDelegate.window.tintColor = UIColor.white 
} 
0

@Dee。我想你已经在你的其他问题之一中问过这个部分了。在这种情况下,您无法显示预览控制器。在这个问题中,建议的答案是从该委托方法返回“自我”。如果您正确实现了该功能,则预览将使用与其父控制器所使用的颜色相同的导航栏颜色。我的意思是如果你已经直接从一些ViewController打开UIDocumentInteractionController,那么UIDocumentInteractionController将使用它的父级viewController的导航栏颜色。这可能会帮助你改变完成按钮的颜色

+0

我现在可以修改导航栏按钮标题,文本和背景颜色。但底部的工具栏颜色不起作用。您能否帮我解决这个问题 – Dee

+0

@Dee我无法修改导航栏按钮的标题,文字和背景颜色。你是怎么做到的? –

0

我解决了它。这里是为我工作的代码完美:

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 
} 
-1
 let QLNavAppearance = UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]) 
    QLNavAppearance.tintColor = UIColor.red // some 
    QLNavAppearance.barTintColor = UIColor.red // some 
    QLNavAppearance.backgroundColor = UIColor.red // some 
0

这是一个有点哈克为依托的事实,QLPreviewController是实施UIDocumentInteractionController类,但这样的事情是侵入性最小的解决方案。在显示UIDocumentInteractionController之前执行此操作

import QuickLook 

UIBarButtonItem.appearance(whenContainedInInstancesOf [QLPreviewController.self]).tintColor = UIColor.black 
相关问题