美文网首页
颜色值#FFFFFF转r g b值

颜色值#FFFFFF转r g b值

作者: o本是后山人o偶作前堂客o | 来源:发表于2019-08-21 15:20 被阅读0次

        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值

          本文链接:https://www.haomeiwen.com/subject/dotisctx.html