Search code examples
iphonexcodeuibarbuttonitemuicolortint

Tint of UIBarButtonItem doesn't match color I set


The background color for my view in RGB format is R: 111/255 G: 209/255 B: 229/255

I tried setting the tint of the UIBarButtonItem using:

CGFloat nRed=111.0/255.0;
CGFloat nGreen=209.0/255.0;
CGFloat nBlue=229/255.0;
UIColor *myColor=[[UIColor alloc]initWithRed:nRed green:nBlue blue:nGreen alpha:1];
[[UIBarButtonItem appearance] setTintColor:myColor];

The color does change for all the UIBarButtonItems I have in the project...but it is still noticeably different from the color of my background. Any thoughts?


Solution

  • You don't need to call the appearance method. Just do this:

    //Suppose you have a variable barButtonItem
    barButtonItem.tintColor = [UIColor blueColor];