基本的に数字が入った正方形である UITableViewCell の画像を動的に作成したいと思います。正方形は色 (動的に指定) である必要があり、その中にテキストとして数字が含まれています。
CGContextRef のドキュメントを見てきましたが、指定された特定の色で画像を塗りつぶす方法がわかりません。
これは私がこれまで試してきたことです。
-(UIImage*)createCellImageWithCount:(NSInteger)cellCount AndColour:(UIColor*)cellColour {
CGFloat height = IMAGE_HEIGHT;
CGFloat width = IMAGE_WIDTH;
UIImage* inputImage;
UIGraphicsBeginImageContext(CGSizeMake(width, height));
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
// drawing code goes here
// But I have no idea what.
UIGraphicsPopContext();
UIImage* outputImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return outImage;
}