Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • I don't think we can decide for you, what you consider "red". You could probably set some criteria based on the ratio of say r/g and r/b, and if those ratios are high enough, call it red. But you'll have to experiment to see what criteria meet your needs. Commented May 15, 2013 at 21:15
  • @rdelmar I know this is all subjective but I guess anything that is pretty close to "Red" will do? Maybe the strongest rgb color component that stands out of the three will classify it as Red? Commented May 15, 2013 at 21:19
  • Do you need to do this for all of the standard named UIColor values or just "red"? Commented May 15, 2013 at 21:36
  • You can get the hue, saturation, brightness, and alpha values of your colors (with getHue:saturation:brightness:alpha:), and see if the hue is close enough to 0 (or 1, red is at both ends of the scale) and the brightness is above a certain threshold. That would be the easiest way, I think. Commented May 15, 2013 at 21:41
  • @rdelmar Does the getHue:... method work on a UIColor created with RGB? Commented May 15, 2013 at 21:44