What is the easiest way to get a hex color code from a set of color percentages in Objective-c?
[self getHexFromRed:0.5 Green:0.5 Blue:0.5]; // returns @"7F7F7F"
I've found several functions for going the other way (creating a color from a hex code), but I c开发者_运维百科an't seem to find any easy way to do this...
Thanks for any help,
ChrisYou could write it from scratch:
[NSString stringWithFormat:@"%02X%02X%02X", 255 * redAsFloat,
255 * greenAsFloat,
255 * blueAsFloat];
精彩评论