Get Slightly Lighter and Darker Color from UIColor
I was looking to be able to turn any UIColor into a gradient. The way I am intending to do this is by using Core Graphics to draw a gradient. What I am trying to do is to get a color, lets say: [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0]; and get a UIColor which is a few shades darker and a few shades lighter. Does anyone know how to do this? Thank you. - (UIColor *)lighterColorForColor:(UIColor *)c { CGFloat r, g, b, a; if ([c getRed:&r green:&g blue:&b alpha:&a]) return [UIColor colorWithRed:MIN(r + 0.2, 1.0) green:MIN(g + 0.2, 1.0) blue:MIN(b + 0.2, 1.0) alpha:a]; return nil; }