• UIImage+PYJColorBecomeImage


    UIImage+PYJColorBecomeImage.h:

    //
    //  UIImage+PYJColorBecomeImage.h
    //  颜色转成图片
    //
    //  Created by PengYunjing on 16/8/24.
    //  Copyright © 2016年 PYJ. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface UIImage (PYJColorBecomeImage)
    
    + (UIImage*)imageWithColor:(UIColor*)color;
    
    @end

    UIImage+PYJColorBecomeImage.m:

    //
    //  UIImage+PYJColorBecomeImage.m
    //  颜色转成图片
    //
    //  Created by PengYunjing on 16/8/24.
    //  Copyright © 2016年 PYJ. All rights reserved.
    //
    
    #import "UIImage+PYJColorBecomeImage.h"
    
    @implementation UIImage (PYJColorBecomeImage)
    
    + (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;
    }
    
    @end
  • 相关阅读:
    Graphviz安装配置
    固定ip
    机器学习基础
    研究生入学感悟
    复试临时练习
    复试临时练习
    Dev-C++回文数遇到的小麻烦
    单例模式
    工厂方法模式
    Spark的checkpoint详解
  • 原文地址:https://www.cnblogs.com/pengyunjing/p/6036221.html
Copyright © 2020-2023  润新知