I am having two controller with different navigation bar color. let say I want to set first controller with navigation bar black color and TitleTextAttributes color whiteColor and after navigate to second controller it change navigation bar white color and TitleTextAttributes black color. navigation bar color change but title text attribute is not changing. Please suggest.
i write this code and used in viewWillAppear method.
Inside navigation bar category
typedef NS_ENUM( NSUInteger, UINavigationBarColor) {
White,
Black
};
+(void)setNavigationColor:(UINavigationBarColor)color{
if (color == White) {
[[self appearance] setTintColor:[UIColor whiteColor]];
NSDictionary *attributes = @{NSForegroundColorAttributeName:[UIColor blackColor]};
[[self appearance] setTitleTextAttributes:attributes];
} else {
[[self appearance] setTintColor:[UIColor blackColor]];
NSDictionary *attributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
[[self appearance] setTitleTextAttributes:attributes];
}
}