Reputation: 41
I understand that you are able to change the title of a Navigation item by calling the SetTitle method navigationItem like so:
[[ViewController navigationItem] setTitle:@"Hello World"];
However, i would like to do more then just change the text of the Navigation Item, I would like to change the colour and font style.
Are there any functions that allow you to change the colour of the Navigation Bar Title?
Upvotes: 2
Views: 4507
Reputation: 1943
You can simply add and modify the following code in viewdidload method. Or you even can put a image on the navigation bar
if ([[UINavigationBar class]respondsToSelector:@selector(appearance)]) {
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"image.png"] forBarMetrics:UIBarMetricsDefault];
}
[[UINavigationBar appearance] setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColor whiteColor],
UITextAttributeTextShadowColor : [UIColor blackColor],
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(1, 0)],
UITextAttributeFont : [UIFont fontWithName:@"System" size:25.0]
}];
Hope this help
Upvotes: 12
Reputation: 5707
Each UINavigationController's navigation bar is made up of navigation items. You can use the UINavigationItem property titleView, and return to it a custom view that contains whatever font size, color, style, etc. that you want.
Upvotes: 0