If you want to use RGB values (Red, Green and Blue) for the iPhone, you might find it hard to source any examples.
Not, however, if you are reading this!!
I found out that in iPhone coding, ’0′ is off and ’1′ is fully on. It’s the values in between zero and one that make up the other values of the colours!!
Now, before your head starts to explode on how to work this out, it’s really quite easy.
RGB values range from ’0′ to ’255′. In order to use this value in your code, you simple divide it by 255.
For example;
Black in RGB values would be Red = 255, Green = 255, Blue = 255, which would produce the colour Black.
In the iPhone code, this should translate to to Red = 1, Green = 1, Blue = 1.
The code to do this is as follows;
//Create the integer variables int Red, Green, Blue; Red = 23; Green = 45; Blue = 189; // Set the colour of the font!! UIColor *myColor = [UIColor colorWithRed:(Red / 255.0) green:(Green / 255.0) blue:(Blue / 255.0) alpha: 1]; myLabel.textColor = myColor;
All you do is change the code for assigning the Red, Green and Blue variables to your coding requirements and you are ready to go!
Happy coding.
Graham