0

我有一個問題我改變動態顏色我navigationbar。我想讓我的navigationbar就像第二個屏幕一樣。顏色navigationController

任何幫助,將不勝感激:)

這是我的代碼:

self.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:(76/255.0) green:(170/255.0) blue:(255/255.0) alpha:1.0]; 

結果:

enter image description here

什麼,我想:

enter image description here

+0

只是爲了ios7設定[self.navigationController.navigationBar setTranslucent:NO]; –

+0

Write Like this Change根據你的... self.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:215.0f/255.0f green:215.0f/255.0f blue:215.0f/255.0f alpha:1.0f]; –

回答

4

嘗試...

 self.navigationController.navigationBar.backgroundColor=[UIColor colorWithRed:215.0f/255.0f green:215.0f/255.0f blue:215.0f/255.0f alpha:1.0f]; 

對於iOS> 7

self.navigationBar.barTintColor=[UIColor colorWithRed:215.0f/255.0f green:215.0f/255.0f blue:215.0f/255.0f alpha:1.0f]; 
    self.navigationBar.tintColor = [UIColor whiteColor]; 
    self.navigationBar.translucent = NO; 
+0

當我設置'[self.navigationController.navigationBar setTranslucent:NO]時,它變成了白色;' – Armanoide

+0

更改背景顏色請....... –

+0

我以相同的順序調用命令,但它是白色的。 – Armanoide

0

更新您的代碼如下所示,並嘗試:

self.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:(76.0f/255.0) green:(170.0f/255.0) blue:(255.0f/255.0) alpha:1.0f]; 
+0

這段代碼似乎沒有任何變化。 – Armanoide

0

而是改變顏色的,由圖像替換它。

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault]; 
0
- (void)customizeUserInterface 
{ 
    if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) 
    { 
     [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]]; 

    } else 
    { 
     [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; 
     [[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]]; 
    } 
} 
1
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"imgNavigationbar.png"] forBarMetrics:UIBarMetricsDefault];