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;
    }

  • 相关阅读:
    Count_sort C++
    Priority_Queue C++
    HeapSort C++
    Randomized_QuickSort C++
    QuickSort c++
    我的开发环境
    github and eclipse
    centos 7 install eclipse cdt and use github
    github commands
    文化-梁晓声
  • 原文地址:https://www.cnblogs.com/yujidewu/p/5290952.html
Copyright © 2011-2022 走看看