自定义字体 - 无法选择它 [英] Custom font - Can't select it
问题描述
我已经下载了一个ttf文件,用于我想在我的应用中使用的自定义字体。
I have download a ttf file for a custom font I want to use in my app.
我已将其添加到我的支持文件中,修改了我的.plst文件,以便有一个名为应用程序提供的字体的新条目,然后将值设置为我的字体文件的文件名(复制和粘贴,所以没有拼写错误)。
I've added it to my supporting files, amended my .plst file so that there's a new entry called "fonts provided by application" and then set the value to the filename of my font file (copied and pasted so no typos).
我还检查了它包含在我的构建阶段,复制捆绑资源。
I've also checked it's included in my Build phases, Copy bundle resources.
当我现在选择一个标签,然后去更改字体时,我的自定义字体不是那里。
When i now select a label and then go to change the font, my custom font is not there.
我错过了一步吗?
谢谢
推荐答案
首先你需要安装那些特殊的字体
现在这些字体就像是带有数组的家庭字体,所以你可以像这样编码
First you have to install those particular fonts now those fonts are like family fonts with array so you can code like this
NSArray * arrFont = [UIFont fontNamesForFamilyName:@你的字体名称];
NSArray *arrFont = [UIFont fontNamesForFamilyName:@"Your font name"];
[lbl1 setFont:[UIFont fontWithName:[arrFont objectAtIndex:0] size:16]];
[lbl2 setFont:[UIFont fontWithName:[arrFont objectAtIndex:1] size:16]];
这篇关于自定义字体 - 无法选择它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!