Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change UINavigationItem colour

I need to set custom colors to my UINavigationBar buttons. I'm doing the following thing(RGB func is a define):

- (void)viewWillAppear:(BOOL)animated
{

for (UIView *view in self.navigationController.navigationBar.subviews)      
    if ([[[view class] description] isEqualToString:@"UINavigationButton"])
        [(UINavigationButton *)view setTintColor:RGB(22.0,38.0,111.0)];

 }

Everything looks fine on app load. after leaving the view and getting back the color returns to default.

Secondly I need to set the same colour to UISegmentedControl to a pressed button.

like image 292
Misha Avatar asked Nov 13 '22 17:11

Misha


1 Answers

[Change UINavigationItem colour](http://www.skylarcantu.com/blog/2009/11/05/changing-colors-of-uinavigationbarbuttons/"Changing colors of UINavigationBarButtons") and to set same color to UISegmentControl will help you to reach to your destination.

Here is a sample code for to set color to UISegmentControl.

like image 137
alloc_iNit Avatar answered Dec 24 '22 20:12

alloc_iNit