HSV/HSB from UIColor

UIColor is a little limited in comparison to its Mac OS X counterpart NSColor. Ars Technica wrote up a handy set of additions which provide add-on methods for doing things like grabbing the -red, -green, and -blue component values from the underlying CGColorRef.

One thing the Ars code seemed to be missing was the ability to pull hue, saturation, and brightness values from a UIColor. So if you need to get those, here is an easy add-on category which piggybacks on Ars’ code.

Source code:

UIColor-HSVAdditions.h

UIColor-HSVAdditions.m

PS: I hope everyone has a fun New Years Eve. Be safe. :)

Comments are closed.