zoukankan      html  css  js  c++  java
  • 十六进制的RGB转换过成color

    if(hex.length == 3){

            hex = [hex stringByAppendingString:hex];

        }

        NSString *red = [hex substringToIndex:2];

        NSString *green = [hex substringWithRange:NSMakeRange(2, 2)];

        NSString *blue = [hex substringFromIndex:4];

        unsigned int redI = 255;

        unsigned int greenI = 255;

        unsigned int blueI = 255;

        

        NSScanner *scan_red = [NSScanner scannerWithString:red];

        [scan_red scanHexInt:&redI];

        

        NSScanner *scan_green = [NSScanner scannerWithString:green];

        [scan_green scanHexInt:&greenI];

        

        NSScanner *scan_blue = [NSScanner scannerWithString:blue];

        [scan_blue scanHexInt:&blueI];

        

        UIColor *color = [UIColor colorWithRed:redI/255.0 green:greenI/255.0 blue:blueI/255.0 alpha:1.0];

  • 相关阅读:
    GCC编绎详解
    GUN C/C++ __attribute__ 用法 转
    rust 参考的资料 转
    Eclipse环境安装rust
    GNU Debugger for Windows----GDB
    minGW cygwin gnuwin32
    tdm-gcc
    GNU tools
    The MinGW and mingw-w64 projects.----GCC
    crosstool-NG
  • 原文地址:https://www.cnblogs.com/chenfeichenyang/p/9646057.html
Copyright © 2011-2022 走看看