How can I modify a UIColor's hue, brightness and saturation?

ios, iphone, uicolor, uikit, xcode

Solution

You can call `getHue:saturation:brightness:alpha:` on your color, then adjust the values, then create a new color with your adjusted components using `+[UIColor colorWithHue:saturation:brightness:alpha:]`

CGFloat hue, saturation, brightness, alpha ;
BOOL ok = [ <color> getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha ] ;
if ( !ok ) { 
    // handle error 
}
// ... adjust components..

UIColor * newColor = [ UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:alpha ] ;

Problem

Lets say I have a UIColor ``` UIColor *color = [UIColor redColor]; ``` Now I want to modify the saturation/hue/brigthness, how do I do that? I did read the documentation but i'm still really confused I want to modify the UIColor I made ([UIColor redColor]) not initiate a new color with some preferences. How do I modify it retaining the original. I do know about the`colorWithHue:saturation:brightness:alpha:` method, I need to update an existing color's properties, keeping the red color.

Original source

Related problems