Today i am going to share few common problems that iOS Developers face at the time of development when they use UINavigationController in Application :-
First, What is Navigation Controller in iOS Programming?
Answer :- A navigation controller maintains a stack of view controllers, when we use navigation controller in Application , we need to specify first view the user sees and manages the navigation of hierarchical content.
UINavigation Controller Official Reference
Now come to our problems of Navigation controller
Problems :-
1. How to change the color of Navigation Bar title ?
--> You need to do this only once when your Root view controller load first time,
Objective C :-
First, What is Navigation Controller in iOS Programming?
Answer :- A navigation controller maintains a stack of view controllers, when we use navigation controller in Application , we need to specify first view the user sees and manages the navigation of hierarchical content.
UINavigation Controller Official Reference
Now come to our problems of Navigation controller
Problems :-
1. How to change the color of Navigation Bar title ?
--> You need to do this only once when your Root view controller load first time,
Objective C :-
[self.navigationController.navigationBar setTitleTextAttributes:
@{NSForegroundColorAttributeName:[UIColor yellowColor]}];
if we want to change font color or more properties with text color then we can use this lineNSDictionary *titlewithMuchAttribute = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],UITextAttributeTextColor,
[UIColor blueColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(-1, 0)], UITextAttributeTextShadowOffset, nil];
[[UINavigationBar appearance] setTitleTextAttributes: titlewithMuchAttribute
];
Swift :-UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.whiteColor()]
2. Change the color of Navigation Bar
-->
Objective C :-
self.navigationController.navigationBar.barTintColor = [UIColor greenColor];
self.navigationController.navigationBar.translucent = NO;
Swift :-
self.navigationController?.navigationBar.barTintColor = UIColor.redColor()