文字列変数からイメージを作成しています。以下は、イメージを作成するためのコードスニペットです
-(UIImage *)imageFromText:(NSString *)text FontName:(UIFont *)font
{
//set the font type and size
//UIFont *font = [UIFont systemFontOfSize:20.0];
CGSize size = [text sizeWithFont:font];
UIGraphicsBeginImageContext(size);
[text drawAtPoint:CGPointMake(0.0, 0.0) withFont:font];
//transfer image
CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES);
CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
上記のコードは正常に動作しますが、最終的な画像がぼやけるという問題があります。
上記のコードに何か問題がある場合はアドバイスをお願いします。