Comment puis-je obtenir une chaîne hexadécimale de UIColor ou de rvb

Maintenant je peux convertir une chaîne hexadécimale de la couleur de rvb comme ceci:

//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 comment puis-je convertir rvb en hexadécimal chaîne?

Regardez cela, eu une belle réponse de stackoverflow.com/questions/3723846/...

OriginalL'auteur xushunwang | 2012-12-27