//This will change the color of the navigation bar
#import <Foundation/Foundation.h>
@interface NavigationDelegate : NSObject<UINavigationControllerDelegate> {
}
@end
NavigationDelegate.m
#import "NavigationDelegate.h"
@implementation NavigationDelegate
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
CGRect frame = CGRectMake(0, 0, 200, 44);//TODO: Can we get the size of the text?
UILabel* label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor yellowColor];
//The two lines below are the only ones that have changed
label.text=viewController.title;
viewController.navigationItem.titleView = label;
}
@end
- (void)viewDidLoad
{
[super viewDidLoad];
//I am using UIColor yellowColor for an example but you can use whatever color you like
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor yellowColor]};
//change the title here to whatever you like
self.title = @"Home";
// Do any additional setup after loading the view.
}