Is it possible to set titleTextAttributes UINavigationBar with the UIAppearance API?

My application contains a UITabrBar with a UINavigationController on each tab. Instead of setting the titleTextAttributes of all the navigation bars, can I use the UIAppearance API?

Now my code looks like

NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, 0, UITextAttributeTextShadowOffset, nil]; navController.navigationBar.titleTextAttributes = textTitleOptions; bNavController.navigationBar.titleTextAttributes = textTitleOptions; meNavController.navigationBar.titleTextAttributes = textTitleOptions; 

I would like to do something like

 [[UINavigationBar appearance] setTitleTextAttributes:navBarTintColor]; 

but the setTitleTextAttributes method does not exist.

Am I missing something obvious?

+4
source share
1 answer

The following work.

 [[UINavigationBar appearance] setTitleTextAttributes: textTitleOptions]; 

What happens when you try to run this code?

+7
source

Source: https://habr.com/ru/post/1403354/


All Articles