Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color of UIToolbar not changing

I have created a UIToolbar. I am trying to give it black color using:

toolbar.barStyle = UIBarStyleBlackOpaque;

or

toolbar's background property. But its color does not change in either case.

How can I change it?

like image 222
Ali Avatar asked Apr 07 '11 13:04

Ali


2 Answers

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 82
Ashish Avatar answered Oct 06 '22 08:10

Ashish


Have you tried setting the tint property on UIToolbar? ie:

- (void)viewDidLoad {
  [super viewDidLoad];
  UIToolbar *toolbar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 46)];
  toolbar.tintColor=[UIColor redColor];
  [self.view addSubview:toolbar];
  [toolbar release];
}

Detailed in the apple docs

like image 38
Twelve47 Avatar answered Oct 06 '22 09:10

Twelve47