There was no problem with whole color for buttons and bar, using the UINavigationBar tintColor proprerty I set the desired color, but when the UINavigationItem title time becomes it was more difficult. We have to forget the UINavigationItem title proprerty and work with titleView one. This proprerty can be fulfilled with any UIView object, in my case I used a UILabel, but I have to set a different titleView for my different UIViewControllers so I encapsulated this in the function that I make available for you.
+ (UILabel*) labelForNavigationItem:(NSString*)textAnd assign the corresponding proprerty on viewDidLoad function
{
UILabel *titleView = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120, 30)] autorelease];
[titleView setFont:[UIFont boldSystemFontOfSize:16.0]];
titleView.backgroundColor = [UIColor clearColor];
titleView.textAlignment = UITextAlignmentCenter;
titleView.textColor = [UIColor colorWithRed:.80784314 green:.77647079 blue:.50980392 alpha:1.0];
titleView.textColor = [UIColor whiteColor];
titleView.text = text;
return titleView;
}
self.navigationItem.titleView = labelForNavigationItem:@"Menu";That's all.
But at last I found a problem that I wasn't able to accomplish. I want to keep the standard UINavigationController backButton, but how could I change its font color? I think its no possible (at least without using an image), but if someone has any answer I would be grateful.
Enjoy it!
No comments:
Post a Comment