2013-09-30 25 views
5

Chciałbym zmienić kolor tła paska nawigacyjnego na zielony.Kolor tła paska nawigacyjnego - półprzezroczystość to nie

Reguła: Nie mogę bałagan z AppDelegate :)

próbowałem:

//It's green but it's translucent 
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; 

//It's white, first line has no effect 
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; 
[self.navigationController.navigationBar setTranslucent:NO]; 

//Same result as case 1 
[self.navigationController.navigationBar setAlpha:0.0f]; 
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; 

//Too dark 
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent]; 
[self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; 

//Only affects the back button's color: 
[self.navigationController.navigationBar setTintColor:[UIColor greenColor]]; 

więc wszelkie pomysły?

Dziękuję, nie widziałem również barTintColor i TintColor. Przyjęcie najwcześniejszej odpowiedzi.

+0

Didi użyć storyboard? następnie wybierz viewcontroller iw inspektorze w ramach symulowanych metryk ustaw górny pasek na nieprzezroczysty pasek nawigacyjny – thorb65

Odpowiedz

17

stosujemy poniższy wiersz kodu w metodzie viewController didLoad

self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:29.0f/255.0f green:149.0f/255.0f blue:174.0f/255.0f alpha:1.0f] 
0

Użyj poniższego kodu, który może być pomocny.

navController.navigationBar.barTintColor = [UIColor yourcolor]; 
+0

Co jest źle w powyższej odpowiedzi i mojej odpowiedzi? –

1

Korzystanie ten,

self.navigationController.navigationBar.tintColor=[UIColor colorWithRed:19.0/255.0f green:52.0/255.0f blue:36.0/255.0f alpha:1]; 
0

użycie nieruchomość barTintColor z navigationBar

Powiązane problemy