While working with UIColor
instances, you might want to extract the individual red, green and blue components. UIColor
provides the method -getRed:green:blue:alpha:
to do this, but it's a little tedious. I wrote a few extensions methods that wraps around this so you can call -moComponents
and get the components as an array or -moRed
, -moGreen
, -moBlue
and -moAlpha
separately,
UIColor* someColor; //Get the color from somewhere.
NSLog(@"Red: %f Green: %f Blue: %f alpha: %f", [someColor moRed], [someColor moGreen], [someColor moBlue], [someColor moAlpha]);
You can find the additions on github here and here.
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.
.