颜色值#FFFFFF转r g b值

2019-08-21  本文已影响0人  o本是后山人o偶作前堂客o

    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;

    }

上一篇下一篇

猜你喜欢

热点阅读