我有這個宏在我的頭文件:宏是否比UIColor設置RGB顏色更好?
#define UIColorFromRGB(rgbValue) \
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 \
alpha:1.0]
,我使用這個作爲我的.m文件是這樣的:
cell.textColor = UIColorFromRGB(0x663333);
所以我要問大家這是好還是我應該使用這種方法:
cell.textColor = [UIColor colorWithRed:66/255.0
green:33/255.0
blue:33/255.0
alpha:1.0];
哪一個是更好的方法?
開箱的NSInte像這樣的ger是架構特定的。你可能會考慮讓UIColorFromRGB接受3個參數,但這種做法會挫敗你的目的。 – 2009-08-07 06:52:13