Is there any algorithm that will create different shades for given Hex or RGB value? I have tried with alpha increasing & decreasing but it's not looking good with light colors(ex: white color).
The best way to do this is using HSB colour space.
It's how I did the left hand section of the keyboard in my latest app...
The "shade" of the colour is the H
value and S
value. You can then change the brightness of it by adjusting the B
value.
So if you had a colour like...
HSB - 0.5, 0.9, 0.9 - very light blue
You could create darker shades by changing the B value...
HSB - 0.5, 0.9, 0.3 - dark blue of the same shade.
Create HSB colours like...
UIColor *color = [UIColor colorWithHue:0.5 saturation:0.9 brightness:0.4 alpha:1.0];
In my app I had a "lightest brightness" and a "darkest brightness".
The I worked out the change in brightness for each section by dividing the difference between them by the number of sections.
Using a for
loop I was able to easily create the different section colours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With