Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UiBarButtonItem Same Color as "Done" Button

I want to be able to programatically add a UIBarButtonItem to a Navigation Bar and set it's tint color to the exact same blue shade as Apple's "Done" UIBarButtonItem.

I am already doing this for Apple's red shade in this block of code:

UIBarButtonItem *myDeleteButton = [[UIBarButtonItem alloc] initWithTitle:@"Clear" style:UIBarButtonItemStyleBordered target:self action:@selector(myDeleteItemsMethod:)];
myDeleteButton.tintcolor = [[UIColor alloc] initwithRed:1 green:0.0470275 blue:0.0116515 alpha:1];
self.navigationItem.rightBarButtonItem = myDeleteButton;

I guess all I need are the RGB values.

I'm having a hard time trying to "reverse engineer" a UIBarButtonItem's tint that was made in Storyboard (Can't cast UIColor as text).

And I also realize that Xcode's color palette has an area for "developer" color schemes but it does not appear to include the color for the "Done" button.

like image 725
Demasterpl Avatar asked Nov 28 '22 17:11

Demasterpl


1 Answers

I spent about 15 mins with my DigitalColor Meter and basically guessed and checked until I finally got it. The problem is that you're adding a "tint" to a black button to make it blue, so it won't be the right blue. Here's the correct measurements:

[buttonName setTintColor:[UIColor colorWithRed:34.0/255.0 green:97.0/255.0 blue:221.0/255.0 alpha:1]];

Hope it helps someone :)

like image 111
Morgan.J.Kennedy Avatar answered Dec 07 '22 00:12

Morgan.J.Kennedy