回答

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 
相關問題