2017-02-24 85 views
0

我在任何視圖控制器中添加導航欄。但是,我在項目中添加了新的CollectionView控制器。我的問題是,我不能添加導航欄收集視圖控制器
所以我添加了代碼的導航欄。我選擇頂部欄 - 「推斷在屬性檢查器中。這是代碼。

導航欄背景顏色光與斯威夫特3

//Add Navigation Bar 

    let height: CGFloat = 65 
    let navbar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: height)) 
    navbar.delegate = self 
    UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green:49.0/255.0, blue:79.0/255.0, alpha:0.1) 
    UINavigationBar.appearance().tintColor = UIColor.white 
    UINavigationBar.appearance().isTranslucent = true 
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white] 

但是,在集合視圖控制器導航欄背景顏色比其他視圖控制器有點暗。
在其他視圖控制器中,我拖放導航欄。
- 導航欄風格 - >黑
- 半透明 - >未啓用
- 酒吧色調顏色 - >#00314F
我不知道爲什麼在集合視圖控制器導航欄的底色是淺比集合視圖控制器。
請幫助我如何匹配所有視圖控制器中的導航欄背景顏色。
如果不容易做,有沒有什麼方法可以在CollectionViewController中添加導航欄而不嵌入導航控制器並且沒有代碼。

回答

0

這是因爲我覺得半透明。當導航欄不透明時,視圖無法定位到導航欄後面以顯示它的內容。但是,當半透明時,視圖會留在導航欄後面,並且視圖的顏色會變得更暗。

+0

嗨@AtaerCaner,你有什麼想法解決這個問題兄弟? –