Question

I got a problem when i change dynamically the color of my navigationbar. I would like get my navigationbar like the second screenShot.

any help would be appreciated :)

This is my code:

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

The result:

enter image description here

what i would like:

enter image description here

Was it helpful?

Solution

Try it ...

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

For 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;

OTHER TIPS

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"imgNavigationbar.png"] forBarMetrics:UIBarMetricsDefault];

Update your code as follows and try:

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

Instead of changing color, replace it by an image.

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];
- (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]];
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top