Thursday, December 9, 2010

Monotouch - Set custom RGB colors.

If you have a custom color with its corresponding RGB values, you can create a new UIColor variable by using the following code.

   float red = 0.0f;           // Defines the red component of the color object. This range is from 0.0f to 255.0f
   float green = 255.0f;       // Defines the green component of the color object. This range is from 0.0f to 255.0f
   float blue = 0.0f;          // Defines the blue component of the color object. This range is from 0.0f to 255.0f
   float alpha = 1.0f;         // Defines the opacity value of the color object. This range is from 0.0f to 1.0f

   UIColor newColor = new UIColor(red/255.0f, green/255.0f, blue/255.0f, alpha);
 

Following website is helpful if you are looking for RGB values for a color.
http://www.colorschemer.com/online.html

No comments:

Post a Comment