2016-05-25 239 views
1

無着色顏色的的導航欄我有UINavigationController的擴展,它設置navigationBar.tintColor,使之透明:斯威夫特

self.navigationBar.tintColor = UIColor.whiteColor() 
self.navigationBar.shadowImage = UIImage() 
self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default) 

但我想有是有一個透明的導航欄,可見項目根本沒有淺色。我補充一點,有一個彩色的背景圖像的右側導航欄項目:

let rightButton = UIBarButtonItem(image: UIImage(named: "avatar")!, 
            style: UIBarButtonItemStyle.Plain, 
            target: self,  
            action: #selector(self.rightNavBarItemAction)) 

navigationItem.rightBarButtonItem = rightButton 

而是具有圖像作爲按鈕的背景下,我得到一個白色的佔位符。使用UIColor.clearColor()使按鈕透明。

+0

http://stackoverflow.com/questions/17041778/uinavigationbar-set-tintcolor-tested-in-ios7-not-working嘗試此鏈接,默認背景色調顏色是白色。 –

+0

@ManishSingh默認爲藍色 – Carpsen90

+0

嘗試設置barTintColor爲clearColor –

回答

0

你可以試試這個:

self.navigationController?.navigationBar.barTintColor = UIColor.green 

enter image description here

希望它爲你工作。由於