jasu's blog
블로그 메뉴검색결과 리스트
RGB에 해당되는 글 1건
- 2012.04.04 UIColor 매크로(RGB, RGBA, HTML) 1
글
UIColor 매크로(RGB, RGBA, HTML)
Programming/Objective-C
2012. 4. 4. 17:49
#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]
#define HTML(rgb) RGB((double)(rgb >> 16 & 0xff), (double)(rgb >> 8 & 0xff), (double)(rgb & 0xff))
//////////////////////////////////////////////////////////////////////
// Code without the macro
msgLabel.textColor = [UIColor colorWithRed:255/255.0 green:251/255.0 blue:204/255.0 alpha:1];
// Or like this...
msgLabel.textColor = [UIColor colorWithRed:1.0 green:.98 blue:.8 alpha:1];
// Code with macro
msgLabel.textColor = RGB(255, 251, 204);
[label setTextColor:HTML(0xff0000)];
참고 : http://iphonedevelopertips.com/cocoa/uicolor-macros.html