码迷,mamicode.com
首页 > 其他好文 > 详细

把UIColor(纯色值)对象转化成UIImage对象

时间:2015-03-12 11:37:56      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:uicolor   uiimage   

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


把UIColor(纯色值)对象转化成UIImage对象

标签:uicolor   uiimage   

原文地址:http://blog.csdn.net/hherima/article/details/44218529

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!