2016-02-11 32 views
8

預期輸出: 我想將ToolBar顏色更改爲深黑色。如何更改SFSafariViewController ToolBar顏色

實際產量: 工具欄顏色淺灰色。

下面是代碼:

let webViewController = SFSafariViewController(URL: url, entersReaderIfAvailable: true) 
self.navigationController?.toolbar.barTintColor = UIColor.blackColor() 
self.navigationController?.toolbar.tintColor = UIColor.whiteColor() 
self.navigationController?.toolbar.barStyle = UIBarStyle.Black 
self.navigationController?.pushViewController(webViewController, animated: true) 
+1

那麼會發生什麼。你的代碼不工作或者是什麼?請添加更多詳細信息。 – Mayur

+0

@Mack工具欄代碼不會影響SFSafariViewController底部。 – Audi

+0

你嘗試設置tintcolor? – Raju

回答

16

的iOS API 10

SFSafariViewController現在有preferredBarTintColorpreferredControlTintColor屬性來控制工具欄的外觀更新的答案。


原來的答案

SFSafariViewController呈現關閉過程。您只能更改色調顏色,而不能更改條形式或條形色調。

要設置色調顏色,設置Safari瀏覽器控制器的視圖的色調顏色,像這樣:

let sfController = SFSafariViewController(URL: url, entersReaderIfAvailable: true) 
sfController.view.tintColor = UIColor.redColor() 
navigationController?.showViewController(sfController, sender: self) 
+0

我能夠改變導航欄的顏色。但我的客戶端請求是改變工具欄的顏色。 – Audi

+1

@Audi這是不可能的。用Apple打開增強請求。 –

+0

或者您可以使用wkwebview並製作您自己的工具欄 – hariszaman

0

我看不出有什麼辦法改變工具欄的背景顏色,但它有可能改變按鈕的顏色工具欄。

[UIBarButtonItem appearance].tintColor = [UIColor whiteColor]; 

正如我所看到的,外觀或直接在控制器屬性中的所有其他更改都不起作用。