iPhone SDK UIColor in RGB

March 22, 2009 § 2 Comments

It is not easy to find much information on iPhone design. Color is a very important element in dressing up your iphone window view. I am sharing quick tips in finding and matching color on UIColor.

You can assign color to label text “textColor” or label background “backgroundColor” to color name like whiteColor, redColor, or even darkGrayColor.

label.textColor = [UIColor whiteColor];
label.backgroundColor = [
UIColor darkGrayColor];

Mac has DigitalColor Meter in utilities folder. It gives you RGB as Percentage value of the color on your screen. Use the values as decimals. You can use RGB decimals to match your html color with flexibility.

black = [UIColor colorWithRed:0 green: 0 blue:0 alpha:1]; 
white = [UIColor colorWithRed:1 green: 1 blue:1 alpha:1];
grey =  [UIColor colorWithRed:0.5 green: 0.5 blue:0.5 alpha:1];
lightBlue = [UIColor colorWithRed:0.31 green: 0.6 blue:.1 alpha:1];  
pink = [UIColor colorWithRed:1 green: 0.6 blue:0.8 alpha:1];
purple = [UIColor colorWithRed:0.4 green: 0 blue:0.4 alpha:1];
lavender =  [UIColor colorWithRed:0.6 green: 0.6 blue:1 alpha:1];
grassGreen =  [UIColor colorWithRed:0.6 green: 0.8 blue:0 alpha:1];

Apple SDK doesn’t offer much extension on UIColor. At least developer can use RGB values to select the closest color for their color themes.

This Reference explained HTML Color including converting between RGB and hexadecimal.

Another reference organized and sorted hundreds of color in RGB values. You can divide R, G, B value by 255 to get the RGB decimals. Example, white R=255, G=255, B=255. You can convert RGB into decimals to get R=1, G=1, B=1. Then you would get colorWithRed:1 green: 1 blue:1 while it is 100% opacity, alpha = 1.

white = [UIColor colorWithRed:1 green: 1 blue:1 alpha:1];

Where Am I?

You are currently browsing the Color category at Web Builders.