2017-09-14 94 views
3

我有設置欄色調的顏色,當該應用程序啓動一個示例項目:UIDocumentInteractionController不尊重在IOS UINavigationBar的的barTintColor外觀11

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
    UINavigationBar.appearance().barTintColor = UIColor.red 
    return true 
} 

它具有1個視圖控制器(一個UINavigationController的內部),帶這個代碼在它:

@IBAction func launchDocument(_ sender: Any) { 
    if let url = Bundle.main.url(forResource: "example", withExtension: "pdf") {    
     let controller = UIDocumentInteractionController(url: url) 
     controller.delegate = self 
     controller.presentPreview(animated: false) 
    } 
} 

func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController { 
    return self 
} 

在iOS系統10,主視圖控制器和UIDocumentInteractionController具有紅色導航欄。在iOS 11中,UIDocumentInteractionController不是紅色的。這是iOS 11的錯誤嗎?還是有另一種方法來做到這一點?

P.S. - 我知道我可以在代理中返回self.navigationController,但是我需要UIDocumentInteractionController有一個「完成」按鈕,而不是「返回」按鈕

+0

有什麼解決方案嗎? –

回答

1

在我的測試中,iOS 11公開發布時出現同樣的問題遠看起來只有[setBarStyle]

[[UINavigationBar appearance] setBarStyle: UIBarStyleBlack]; 
0

同樣的問題。但我意識到這是關於barTintColorsetBackgroundImage適合我。

  • 與背景顏色創建一個小圖像,並添加此行:

    UINavigationBar.appearance().setBackgroundImage(UIImage.init(named: "nav_bg")?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 15, 0, 15), resizingMode: .stretch), for: .default) 
    
相關問題