How to adjust the highlight color of my UIBarButtonItem?

I use the appearance proxy to configure color options around the world:

//Setup custom appearances if ([UINavigationBar respondsToSelector:@selector(appearance)]) { [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:96.0/255.0 green:13.0/255.0 blue:11.0/255.0 alpha:1.0]]; [[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:96.0/255.0 green:13.0/255.0 blue:11.0/255.0 alpha:1.0]]; //rgb: 96, 13, 11 //[[UIToolbar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault]; [[UIToolbar appearance] setTintColor:[UIColor blackColor]]; } 

This works fine, but when I click on the UIBarButtonItem, which is in my UINavigationbar, it changes color to black. How can I make sure the highlighted state is not black?

+4
source share
2 answers

Check this out: UIBarButtonItem with color?

Make sure you import "QuartzCore / QuartzCore.h" to access the properties of the UIView layer. To import this, you need to add the CoreGraphics infrastructure to your project.

0
source

last line:

 [[UIToolbar appearance] setTintColor:[UIColor blackColor]]; 

maybe it is possible?

+1
source

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


All Articles