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

来源:互联网 发布:java 文件名 问号 编辑:程序博客网 时间:2024/05/18 01:10
+ (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;}


2 0
原创粉丝点击