如何在iOS Apps中使用自定义字体? [英] How to use custom font in iOS Apps?

查看:141
本文介绍了如何在iOS Apps中使用自定义字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

我可以在iPhone应用程序中嵌入自定义字体吗?

您好我想在我的原生iOS应用中使用myanmar字体。

Hi I would like to use myanmar font in my native iOS Apps.

但是我不知道如何使用它字体。

However i don't know how to use that font.

字体名称是Zawgyi.ttf,它是myanmar字体。

Font name is Zawgyi.ttf and It's myanmar font.

我已经在我的字体中安装了该字体macbook和我没有在我的xcode项目的字体属性中找到该字体。

I already installed that font in my macbook and i didn't found that font in my xcode project's font property.

我只是iOS的初学者。

I'm just beginner for iOS.

请指导我怎么做?

感谢您的阅读。

推荐答案

您只需要在资源文件夹中拖动字体的ttf文件,并在info.plist文件中输入后执行此操作 -

You just need to drag the font’s ttf file in your resource folder and do this following entry in your info.plist file –

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

UIAppFonts键接受一个数组,因此你可以在其中传递多种字体。

UIAppFonts key accept a array so you can pass multiple fonts in it.

现在,无论您想在应用程序中使用哪种字体,都可以调用:

Now wherever you want to use the font in your application you can call:

[UIFont fontWithName:@"Cloister Black" size:64.0]

请确保在上面给出真实的字体名称码。字体文件名及其真实字体名称可以不同,所以只需打开FontBook应用程序中的字体,就可以看到字体的真实名称。

Just make sure you give the real font name in above code. The font file name and its "real font name" can be different, so just open the font in FontBook app and there you can see the real name of the font.

请参阅我在此处相同主题的博客文章 - http://www.makebetterthings。 com / iphone / how-to-use-custom-fonts-in-iphone /

See my blog post on same topic here - http://www.makebetterthings.com/iphone/how-to-use-custom-fonts-in-iphone/

这篇关于如何在iOS Apps中使用自定义字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆