Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change front color of navigation bar title

I am using navigation controller in my application and want to change title color of navigationBar.

I am doing so using below code

NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor],UITextAttributeTextColor,nil];
    [self.navController.navigationBar setTitleTextAttributes:dic];

One more thing I am using ARC xcode 4.2 and this code is placed on appdelegate only

It is working fine in ios 4+ but not working on below versions.

Please help me how to do this from single code on appdelegate

like image 682
Shivomkara Chaturvedi Avatar asked Jan 06 '12 09:01

Shivomkara Chaturvedi


People also ask

How do I change the color of my navigation title?

Go to Attributes inspector of Navigation Controller > Navigation Bar and set the desired color in Title Color menu. Save this answer. Show activity on this post.

How do I change the appearance of my navigation bar?

To change the appearance of the navigation bar: Choose “standard” and “scroll edge appearances” for the navigation bar, by setting the appearance proxy of UINavigationBar : “Standard”, and “ScrollEdge” appearances. Open the project's storyboard file. Select the UINavigationBar from your UINavigationController scene.

How do I change the navigation bar title color in SwiftUI?

To change a navigation bar color in SwiftUI, you apply toolbarBackground modifier to the content view of NavigationStack . NavigationView is deprecated in iOS 16. toolbarBackground accepts two parameters. ShapeStyle : The style to display as the background of the bar.

How do I change the navigation bar title font in Swift?

let navigation = UINavigationBar. appearance() let navigationFont = UIFont(name: "Custom_Font_Name", size: 20) let navigationLargeFont = UIFont(name: "Custom_Font_Name", size: 34) //34 is Large Title size by default navigation. titleTextAttributes = [NSAttributedStringKey. foregroundColor: UIColor.


1 Answers

After iOS 5, just do this :

    nav1.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
like image 50
Damien Romito Avatar answered Oct 21 '22 08:10

Damien Romito