UIColor转化为UIImage

来源:互联网 发布:成都网络推广报价 编辑:程序博客网 时间:2024/05/03 13:24

+ (UIImage *)createImageWithColor:(UIColor *)color

{

   CGRect rect = CGRectMake(0.0f,0.0f, 1.0f,1.0f);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context =UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [colorCGColor]);

   CGContextFillRect(context, rect);

    UIImage *image =UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    

   return image;

}

0 0
原创粉丝点击