Search code examples
ios7uitoolbar

UIToolbar setBackgroundColor doesn't fully change color


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.


Solution

  • 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