WeChat/BAQMUIDemo/BAKit/BAKit_UIKit/UIImage/UIImage+BAColor.m
//
//  UIImage+BAColor.m
//  BAKit
//
//  Created by boai on 2017/6/7.
//  Copyright © 2017年 boai. All rights reserved.
//

#import "UIImage+BAColor.h"

@implementation UIImage (BAColor)

/**
 创建一个 纯颜色 图片【全部铺满】

 @param color color
 @return 纯颜色 图片
 */
+ (UIImage *)ba_image_Color:(UIColor *)color
{
    UIImage *image = [self ba_image_Color:color size:CGSizeMake(1.0f, 1.0f)];
    return image;
}

/**
 创建一个 纯颜色 图片【可以设置 size】

 @param color color
 @param size size
 @return 纯颜色 图片
 */
+ (UIImage *)ba_image_Color:(UIColor *)color size:(CGSize)size
{
    CGRect rect          = CGRectMake(0.0f, 0.0f, size.width, size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    
    CGContextFillRect(context, rect);
    UIImage *image       = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}

@end
