문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

In ios7 there are 2 properties:

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

Use barTintColor.

Please remove from you code :

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

and add line

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

and also check your 'getProjectListToolBar' frame coordinates

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top