UIColor 转 UIImage

来源:互联网 发布:网络机顶盒app下载 编辑:程序博客网 时间:2024/05/18 04:52

转载自 http://www.cocoachina.com/bbs/read.php?tid=91425


- (UIImage *) createImageWithColor: (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;}


0 0
原创粉丝点击