Hello,
How can I set UIcolor to have a deepblue values (like 330099, shown in interface builder) programmatically?
Thanks.
Hello,
How can I set UIcolor to have a deepblue values (like 330099, shown in interface builder) programmatically?
Thanks.
Just use Jeff LaMarche's UIColor extensions....
http://iphonedevelopment.blogspot.com/2008/11/more-colors-more-compact.html
and here:
http://iphonedevelopment.blogspot.com/2008/10/little-color-in-your-life.html
You can see how it is done.
To create a UIColor based on RGB values you need to do:
[UIColor colorWithRed:0x33/255.0 green:0 blue:0x99/255.0 alpha:1.0]
Or in stead of using 0x33 / 255.0 use the actual float for the color value, this of course requires you to convert the values.
[UIColor colorWithRed:51.0 / 255.0, green:0.0, blue:153.0 / 255.0];
As long as you use a floating point value in your division you don't have to cast anything. Make sure you use floating point values. For example: 33 / 255 = 0
. Which will become black.