Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationBar How to Title Font color font style

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?

like image 261
RyzBeyond Avatar asked Nov 22 '25 23:11

RyzBeyond


1 Answers

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

like image 95
Clarence Avatar answered Nov 25 '25 12:11

Clarence