如何为绘图文本设置Arial字体样式

时间:2012-10-11 22:24:57

标签: ios

我使用下一个代码创建一个png文件。我需要用Arial 24写一些文字。我怎么能这样做?我找不到可以设置Arial字体样式的位置。

UIImage *image = [BSSharedObject getInstance].downloadedImage;
    UILabel *label = [[UILabel alloc]init];
    UIFont *font = [UIFont systemFontOfSize:24.0];


UIGraphicsBeginImageContextWithOptions(CGSizeMake(WIDTH, HEIGHT), NO, 1.0);
[message drawInRect:CGRectMake(INDENT, INDENT, WIDTH - 2 *INDENT ,600) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentLeft];
[image drawInRect:CGRectMake((WIDTH - INDENT - image.size.width), (HEIGHT - INDENT- image.size.height), image.size.width, image.size.height)];
UIImage *resultImage  = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[BSSharedObject getInstance].createdImage = resultImage;

UIImage *im =  [BSSharedObject getInstance].createdImage;
return resultImage;

1 个答案:

答案 0 :(得分:3)

[UIFont fontWithName:@"Arial" size:24]

这将为您提供所需的字体。可预测地调用systemFontOfSize会导致返回系统字体 - 对于iOS,您会获得Helvetica Neue