Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIToolbar setBackgroundColor doesn't fully change color

Tags:

ios7

uitoolbar

I'm trying to set the background color of a UIToolBar. I tried selecting the color from IB's Attribute Inspector, and tried setting it programmatically through setBackgroundColor:[UIColor ...].

Both solutions work, but only partially: the color blends something like 50% with white and the toolbar is very light...doesn't show the color I actually chose, but a much lighter version of it.

How can I have the UIToolBar of the actual color I'm choosing? It's probably very simple to solve, but I can't find a way and can't find answers online either.

like image 463
BkdD Avatar asked Oct 16 '13 10:10

BkdD


2 Answers

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

like image 198
Jageen Avatar answered Sep 20 '22 19:09

Jageen


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...

like image 22
Ashish Avatar answered Sep 18 '22 19:09

Ashish