zoukankan      html  css  js  c++  java
  • ios 颜色转图片

     - (UIImage *)imageWithColor:(UIColor*) color
    {
        CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
        UIGraphicsBeginImageContext(rect.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetFillColorWithColor(context, [color CGColor]);
        CGContextFillRect(context, rect);
        UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return theImage;
    }
    - (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
    {
        CGRect rect = CGRectMake(0, 0, size.width, size.height);
        UIGraphicsBeginImageContext(rect.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetFillColorWithColor(context,color.CGColor);
        CGContextFillRect(context, rect);
        UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        
        return img;
    }

  • 相关阅读:
    MyBatis+Oracle+Sequence
    原来这就是JVM垃圾
    JVM内存布局
    CacheAsidePattern结论
    The LMAX Architecture
    网络编程
    随机存取文件流
    数据流
    打印流
    标准输入流、标准输出流
  • 原文地址:https://www.cnblogs.com/yujidewu/p/5290952.html
Copyright © 2011-2022 走看看