views:

703

answers:

1

I colorized orange my Navigation bar with:

navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.88 green:0.52 blue:0.27 alpha:1];

Everything works ok, every button is as orange as the bar, but when ic cames to a custom right item menu, it shows it blue. This is a screenshot: http://img146.imageshack.us/img146/5605/schermata20091202a14565.png

and this is the code for the right buttons:

UIView *container = [[UIView alloc] init];

UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 80, 45)];

NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:2];

UIBarButtonItem *bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addGadget:)]; bi.style = UIBarButtonItemStyleBordered; [buttons addObject:bi]; [bi release];

bi = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"less.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(setEditing:)]; [buttons addObject:bi]; [bi release];

[tools setItems:buttons animated:NO]; [buttons release];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools]; [tools release];

Can someone help me in fixing this problem? (I want everything to be orange)

+1  A: 

You should set the tintColor of the UIToolbar object to be the same as that of the UINavigationBar.

Note that a UIToolbar is not the same as a UINavigationBar, the background gradient/color is a bit different. Try setting the backgroundColor of the UIToolbar to +[UIColor clearColor]

Also, you probably don't even need the container UIView, since UIToolbar is a subclass of UIView, so you can use it as customView just by itself.

JoostK
Thanks for your answer.If it set the backgroundcolor to clear, nothing changes.If i set the tint to clear, it gives me a black piece,if i set it to the same orange it lacks of one black pixel on the bottom so it doesn't merge well with the navigationbar
w4nderlust
That's what I said. tintColor should be orange, that's right. You don't want the background to be drawn (since it's different) so I told you to try to set the background color to clear. That doesn't work, so write a `UIToolbar` subclass and override -drawRect: and do nothing, I think that'll be enough.
JoostK
Ok with the subclass it works great, thank you so much!
w4nderlust