简体   繁体   English

IOS 8,自定义字体问题

[英]IOS 8, custom font issue

I added a custom Chinese font to my project, (followed the instruction here ).我在我的项目中添加了自定义中文字体,(按照此处的说明进行操作)。 I only want to set the font for a few buttons, but when i do this in code or in storyboard, all the other labels, buttons, textFields.. are all set to this font too.我只想为几个按钮设置字体,但是当我在代码或故事板中执行此操作时,所有其他标签、按钮、文本字段 .. 也都设置为该字体。 And this only happens to ios8, and it works fine on ios9.而这只发生在ios8上,在ios9上运行良好。 Why did this happen, can anyone help?为什么会发生这种情况,有人可以帮忙吗?

this is my code to set the font:这是我设置字体的代码:

UIFont *hannotate = [UIFont fontWithName:@"Hannotate SC" size:18];
self.button1.titleLabel.font = hannotate;
self.button2.titleLabel.font = hannotate;

this is what i set in storyboard:这是我在故事板中设置的:

在此处输入图片说明

Updation1:更新1:

this is screenshot of my Info.plist, I have change the font name everywhere to "FHTHannotateSC".这是我的 Info.plist 的屏幕截图,我已将到处的字体名称更改为“FHTHannotateSC”。

在此处输入图片说明

Updation2更新2

I printed all the fonts in ios 8 system, and found i was using the font family name(Hannotate SC) as the font name, the real font name is "HannotateSC-W5", so i corrected the font name, and run the APP again, but unluckily, the font is still global set.我在ios 8系统打印了所有字体,发现我用的是字体家族名称(Hannotate SC)作为字体名称,真正的字体名称是“HannotateSC-W5”,所以我更正了字体名称,并运行了APP再次,但不幸的是,字体仍然是全局设置的。

I solved this problem by doing following steps: 1. Go to project target 2. Choose Build Phase option 3. Add the font files in Copy Bundle resources.我通过执行以下步骤解决了这个问题: 1. 转到项目目标 2. 选择 Build Phase 选项 3. 在 Copy Bundle 资源中添加字体文件。

May this help you!愿这对你有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM