I want to change the UINavigationBar
titleColor
.
I also want to change the textColor
of the UINavigationBar
backButton
.
I am using iPhone Os sdk 3.1.2
I want to change the UINavigationBar
titleColor
.
I also want to change the textColor
of the UINavigationBar
backButton
.
I am using iPhone Os sdk 3.1.2
This worked for me.
Using this you can change the color of all of the navigation buttons:
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
Replace redColor with the following to adjust the color of the buttons:
colorWithRed:0/255.0 green:144/255.0 blue:200/255.0 alpha:1.0// pick your color using this
Be sure to put this in the view controller that pushes. Not the view controller where you want to see this back button color.
One part of this question has already been answered.
Then, to change the back button title color, I would suggest creating a custom button with a label:
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:yourViewWithColoredText];
navigationItem.leftBarButtonItem = buttonItem; // assign it as the left button
yourViewWithColoredText
should be a custom view containing your colored text.
Then depending on what you want, you could make it look like a standard back button.
You can set the titleView, defined in UINavigationBar.h as:
@property(nonatomic,retain) UIView *titleView;
// Custom view to use in lieu of a title. May be sized horizontally. Only used when item is topmost on the stack.
Pop your own UILabel in there with whatever color you want.
UIBarButtonItem *button = [[UIBarButtonItem alloc] init];
[button setTintColor:[UIColor redColor]];
Set the title
on UINavigationBar
on iOS 5 & 6
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:UITextAttributeTextColor]];
On iOS 7
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor blackColor]};
Set the textColor
on all UIBarButtonItem
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor, nil];
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState: UIControlStateNormal];