2011-08-12 57 views

回答

4

http://kgriff.posterous.com/45359635是完成此任务的一个很好的教程。

基本上,将一个关键字添加到info.plist文件,并记住使用字体的信息文件中通过元属性分配的字体名称,而不是实际的ttf名称。

在plist中添加一个键“UIAppFonts”。将其值设置为包含字符串“FontName.ttf”的数组。

当然,请确保您已将ttf添加到项目中。

在您的应用程序

现在,使用:

[UIFont fontWithName:@"Font Name as in your Font Book, not the file name" size:12.0f]

+0

非常感谢! – LuckySam

0

更改标签的字体是通过使用UIFont对象来完成:

self.timeLabel.font = [UIFont fontWithName:(NSString *) size:(CGFloat)];

+0

为什么这是downvoted?请澄清。 –

+1

我没有投票,但可能是因为你的回答没有回答这个问题。他问如何在UILabel中使用自定义字体,** custom **是重要的单词。 –

+0

@Shaharyar我低估了你的回答,因为正如贾斯汀所指出的那样,它并没有回答所问的问题。您的答案说明了如何将标签的字体设置为指定字体,但没有说明如何导入自定义字体并使用它。希望提供你正在寻找的说明:) – theChrisKent

0

您可以通过此更改字体代码:

UILabel *label = [[UILabel alloc] init]; 
[label setFrame:CGRectMake(8, 10, 150 ,20)]; 
label.backgroundColor = [UIColor clearColor]; 
label.text = [tableArray objectAtIndex:indexPath.row]; 
label.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:15];