UIToolbar setBackgroundColor doesn't fully change color

Write below code in your viewDidLoad

self.navigationController.toolbar.barTintColor = [UIColor redColor];

It will set red color as your tool bar background.

Reference link https://web.archive.org/web/20160321155823/https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/Bars.html#//apple_ref/doc/uid/TP40013174-CH8-SW5

In it they said that Use barTintColor to tint the bar background. enter image description here


IN iOS 7 you need to set the barTintColor Property-

UIToolbar *doneToolbar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 584, 320, 44)];
doneToolbar.translucent=NO;
doneToolbar.barTintColor=[UIColor redColor];
[self.view addSubview:doneToolbar];

I have used it its working fine...


In addition to Jageen's answer, you must also set the translucent property to false. Otherwise the color will have slightly less saturation and hue than what is specified with barTintColor.

// Sets to a specific color
self.navigationController.toolbar.barTintColor = [UIColor colorWithRed:6.0 / 255.0 green:52.0 / 255.0 blue:90.0 / 255.0 alpha:1.0];

// Without this, color will be faded slightly and not exactly what's specified above  
self.navigationController.toolbar.translucent = false;

Tags:

Uitoolbar

Ios7