tags:

views:

1146

answers:

2

Hi, I have created email functionality view in which everything is working fine, but the color of a navigation bar item is not changing like other views. I have used below code for navigation color but 1 navigation bar button item is left with default color. How do I change it?

controller.navigationBar.barStyle = UIBarStyleBlack;
A: 

Do you create the bar button item yourself? If so, you can change its background color by making sure it's a "custom view" type button item:

// Assuming you have some predetermined width w and height h
UIView *backgroundView = [[[UIView alloc] 
                           initWithFrame:CGRectMake(0.0, 0.0, w, h)] autorelease];
backgroundView.backgroundColor = [UIColor blackColor];
UIBarButtonItem *myItem = [[[UIBarButtonItem alloc]
                            initWithCustomView:backgroundView] autorelease];

Then you can change the background color at a future date by setting the backgroundColor property on the bar button item's customView:

myItem.customView.backgroundColor = [UIColor yellowColor];
Tim
{ MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; NSMutableArray *messgeToField = [[NSMutableArray alloc]init]; NSString *str= @"[email protected]"; [messgeToField addObject:str]; [controller setToRecipients:messgeToField]; [controller setSubject:@"Feedback"]; [controller setMessageBody:@"" isHTML:NO]; controller.navigationBar.barStyle = UIBarStyleBlack; [self presentModalViewController:controller animated:YES]; [controller release]; [messgeToField release];}
i have used this code for email functionality. i am not creating any navigation bar or bar button item not from a nib 2. i have 2 bar buttons item.controller.navigationBar.barStyle = UIBarStyleBlack;this code only changes the color of 1 bar button item. tell me any solution 4 ds
hi tim, i have tried your code, but it's not working too
@Harita: what button isn't changing? If it's the Send button in MFMailComposeViewController, this is desired behavior and I'm not sure there's a way around it. The docs (http://developer.apple.com/iphone/library/documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html) even say that the mail composition interface itself shouldn't be changed.
Tim
yes the send button is not changing
In that case there's not much I can say. The Send button isn't really supposed to be changed.
Tim
A: 

How about use this?

self.navigationController.navigationBar.tintColor = [UIColor blackColor];

of course on your viewDidLoad

Jirapong