码迷,mamicode.com
首页 > 移动开发 > 详细

IOS中UIImage和UIColor相互转化

时间:2015-08-26 18:06:39      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:

//UIColor 转UIImage

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

{

    CGRect rect=CGRectMake(0011);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]);

    CGContextFillRect(context, rect);


    UIImage *senderImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return senderImage;

}


//UIImage转UIColor

[UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];


IOS中UIImage和UIColor相互转化

标签:

原文地址:http://my.oschina.net/linxiaoxi1993/blog/497401

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