简体   繁体   English

自定义字体iphone

[英]custom font iphone

I am trying to add a custom font in my app, searched the web, there are many posts but i am getting error 我试图在我的应用程序中添加自定义字体,在网络上搜索了很多帖子,但我遇到了错误

InfoPlist.strings:0: error: validation failed: The data couldn’t be read because it has been corrupted.

i dont get what's the issue, i added a new file of font in my project and added this code in plist, i never used plist before 我没有得到什么问题,我在我的项目中添加了一个新的字体文件,并将此代码添加到了plist中,我之前从未使用过plist

<key>UIAppFonts</key>
<array>
<string>CloisterBlack.ttf
</string>
</array>

Add font in plist, then check the name of your font, by double clicking the font file in finder, like in my case the name of the font is Abduction for the font file name "CloisterBlack.ttf" 在plist中添加字体,然后通过在finder中双击字体文件来检查字体名称,例如在我的情况下,字体名称是Abduction,字体文件名为“ CloisterBlack.ttf”

then access it like 然后像访问

[UIFont fontWithName:@"Abduction" size:20.0];

I think your font file has been corrupted. 我认为您的字体文件已损坏。 Add it again and then try. 再次添加它,然后尝试。 This link will help you Add Custom Font in your app . 此链接将帮助您在应用程序中添加自定义字体 Make sure your file should be .ttf . 确保您的文件应为.ttf Do you have any .ttf file or not ? 您是否有任何.ttf文件? If YES then add it to you project folder and then make little changes in your info.plist file. 如果是,则将其添加到您的项目文件夹,然后在info.plist文件中进行少量更改。

在此处输入图片说明

If you dont have any .ttf file then download it first. 如果您没有任何.ttf文件,请先下载。 It is your font file. 这是您的字体文件。

只需将此类用于自定义字体

I think adding the extension will fix it, my plist files look the same. 我认为添加扩展名将解决该问题,我的plist文件看起来相同。

<key>UIAppFonts</key>
<array>
<string>CloisterBlack.ttf</string>
</array>

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

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