Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparison of UIColors

Tags:

iphone

uicolor

I have some code which I can't figure out why it's not working,

UIColor *lastColor, *red;
red = [UIColor colorWithRed:0.993 green:0.34444 blue:0.0 alpha:1.0]; 

NSString *chosenColor;

if([lastColor isEqual: red])
{
   chosenColor = @"red";
}

I have also found some people making an override of the isEqual method, isEqualtoColor: But this didn't work either and i fed that one lastColor.CGColor;

Everywhere I've read that isEqual is all you need to compare the UIColors, im currently resorting to an array of strings for red, green and blue and comparing the float value to the CGColorGetComponents(lastColor);

But this isn't working either.

like image 999
Woodmister1 Avatar asked Jan 21 '23 00:01

Woodmister1


1 Answers

gist.github.com/mtabini/716917

The link above works like a charm. Thanks awfully "Count Chocula" both a delicious source of chocolate and iphone answers :P

I'd click answered to your post but it would more then likly misslead any people wondering on here.

Must have just been a float tolerance.

like image 117
Woodmister1 Avatar answered Jan 30 '23 22:01

Woodmister1