【发布时间】:2014-10-15 00:00:09
【问题描述】:
我想在情节提要中将自定义字体设置为 UILabel。我有字体的 .ttf 文件。我在谷歌上搜索过,每个人都在以编程方式设置字体。
【问题讨论】:
-
您必须以编程方式设置自定义字体。
-
uilabel custom font?的可能重复
标签: ios objective-c iphone fonts
我想在情节提要中将自定义字体设置为 UILabel。我有字体的 .ttf 文件。我在谷歌上搜索过,每个人都在以编程方式设置字体。
【问题讨论】:
标签: ios objective-c iphone fonts
选择控件(标签)并添加User Defined Runtime Attribute(Key Path设置为fontName,Type 设置为 String 和 Value 设置为自定义字体的名称)。
注意:
确保您已将字体添加到项目中 - tutorial
【讨论】:
将您的 IBOutlet 连接到 Label,您可以这样设置,
lblHeading.font = [UIFont fontWithName:@"ApexNew-Bold" size:17];
in the above code ApexNew-Bold is custom font and you need to add it in Plistfile.
【讨论】:
好消息是,这是 Xcode 6 中的 Interface Builder 中添加的一项新功能,如文档中所述 here
【讨论】: