UIGraphicsBeginImageContextWithOptions(imagBounds.size, NO, 0);
[color setFill];
UIRectFill(imagBounds);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
原文:http://www.cnblogs.com/huahuahu/p/chan-sheng-chun-se-tu-xiang.html