颜色值#FFFFFF转r g b值

    NSString*hexColor = @"FFFFFF";

    if([hexColor hasPrefix:@"#"])

    {

        hexColor = [hexColor substringFromIndex:1];

    }

    NSScanner*scanner = [NSScanner scannerWithString:hexColor];

    unsigned hexNum;

    int r =0;

    int g =0;

    int b =0;

    if([scanner scanHexInt:&hexNum])

    {

        r = (hexNum >>16) &0xFF;

        g = (hexNum >>8) &0xFF;

        b = (hexNum) &0xFF;

    }

你可能感兴趣的:(颜色值#FFFFFF转r g b值)