Sheehan Alam
Sheehan Alam

Reputation: 60879

How can I adjust the highlight color of my UIBarButtonItem?

I am using the appearance proxy to adjust my color settings globally:

//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 tap on a UIBarButtonItem that is in my UINavigationbar, it changes color to black. How can I make sure the highlighted state is not black?

Upvotes: 4

Views: 3695

Answers (2)

Mason
Mason

Reputation: 7103

Check this out: UIBarButtonItem with color?

Make sure that you import "QuartzCore/QuartzCore.h" in order to access the layer properties of UIView. To import that, you need to have added the CoreGraphics framework to your project.

Upvotes: 0

theWalker
theWalker

Reputation: 2020

last line is:

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

maybe rem it?

Upvotes: 1

Related Questions