Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIToolBar tintColor not working for iOS 7

I have created a UIToolBar in my app that is colored blue, and it showed as blue when I was building it as a iOS 6 but now that I have updated the build to iOS 7 its turned white?

This is my code.

getProjectListToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, 20.0, screenHeight+20, 44)];
getProjectListToolBar.tintColor = [UIColor colorWithRed:85.0/255.0 green:130.0/255.0 blue:186.0/255.0 alpha:1.0];

getProjectListToolBar.translucent = NO;
getProjectListToolBar.layer.borderWidth = 0.0;
getProjectListToolBar.backgroundColor = [UIColor clearColor];
getProjectListToolBar.layer.borderWidth = 0.5;
getProjectListToolBar.layer.borderColor = [UIColor darkGrayColor].CGColor;
[self.view insertSubview:getProjectListToolBar aboveSubview:self.view];

How can I get it blue again?

like image 587
HurkNburkS Avatar asked Dec 16 '22 02:12

HurkNburkS


2 Answers

You just need to set

getProjectListToolBar.translucent = NO;

In iOS 7 UITabBar and UINavigationBar has translucent property and for both you need to set translucent = NO , Its just for your information.

EDITED

[getProjectListToolBar setBarTintColor:[UIColor colorWithRed:85.0/255.0 green:130.0/255.0 blue:186.0/255.0 alpha:1.0]];

Because in iOS 7 you need to set barTintColor instead of tintColor from this documentation.

I tried with your code in my demo project and it worked for me.

like image 93
iPatel Avatar answered Dec 23 '22 13:12

iPatel


In ios7 there are 2 properties:

  1. tintColor: Will set color of toolbar item
  2. barTintColor : will set color of toolbar

Use barTintColor.

like image 42
vivek bhoraniya Avatar answered Dec 23 '22 14:12

vivek bhoraniya