2010年11月9日火曜日

UIColorの便利な定義

hファイルで以下を定義するとrgbカラー指定が楽になる
#define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

使用例
//色のみ
 testLabel.textColor = RGB(255, 251, 204);
//透過も指定
 testLabel2.textColor = RGBA(255, 251, 204, 0.5);

*参考記事*
UIColor Macros