現在,我可以轉換一個十六進制字符串RGB顏色是這樣的:我怎樣才能得到一個十六進制字符串從的UIColor或RGB
// Input is without the # ie : white = FFFFFF
+ (UIColor *)colorWithHexString:(NSString *)hexString
{
unsigned int hex;
[[NSScanner scannerWithString:hexString] scanHexInt:&hex];
int r = (hex >> 16) & 0xFF;
int g = (hex >> 8) & 0xFF;
int b = (hex) & 0xFF;
return [UIColor colorWithRed:r/255.0f
green:g/255.0f
blue:b/255.0f
alpha:1.0f];
}
BU我如何轉換RGB到十六進制字符串?
看看這個,有一個很好的答案的http://計算器。 COM /問題/ 372 3846/convert-from-hex-color-to-rgb-struct-in-c –