Tuesday, February 2, 2010

Convert RGB to HEX


// Convert the RGB numbers to hex strings
NSString *redHexValue=[NSString stringWithFormat:@"%02x", redIntValue];
NSString *greenHexValue=[NSString stringWithFormat:@"%02x", greenIntValue];
NSString *blueHexValue=[NSString stringWithFormat:@"%02x", blueIntValue];

// Concatenate with a "#"
NSString * hexColor = [NSString stringWithFormat:@"#%@%@%@",
redHexValue,greenHexValue, blueHexValue];

No comments:

Post a Comment