//顏色轉(zhuǎn)圖片
- (UIImage *)imageWithColor:(UIColor *)color
{
// 描述矩形
CGRect rect? ? ? ? ? = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
// 開啟位圖上下文
UIGraphicsBeginImageContext(rect.size);
// 獲取位圖上下文
CGContextRef context? = UIGraphicsGetCurrentContext();
// 使用color演示填充上下文
CGContextSetFillColorWithColor(context, [color CGColor]);
// 渲染上下文
CGContextFillRect(context, rect);
// 從上下文中獲取圖片
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
// 結(jié)束上下文
UIGraphicsEndImageContext();
return theImage;
}