在iOS中,是否可以在运行时向应用程序添加字体? [英] In iOS, Is it possible to add a font to the app during runtime?

查看:101
本文介绍了在iOS中,是否可以在运行时向应用程序添加字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我想让用户下载并使用字体,但我不知道如何动态地执行此操作。我知道我们必须在应用程序的 Info.plist 文件中指定我们要使用的字体,但我们无法以编程方式向该plist文件添加任何内容。有zynga的库,但它是 UILabel 的子类。

In my app I want to let the user download and use fonts, but I don't know how to do this dynamically. I know we have to specify the fonts we want to use in the app's Info.plist file, but we can't add anything to that plist file programmatically. There is zynga's library but it is a subclass of UILabel.

请帮助

推荐答案

您可以使用 CGFontCreateWithDataProvider()后跟 CTFontCreateWithGraphicsFont()。那么你有一个CTFont,你可以使用Core Text绘制。

You could use CGFontCreateWithDataProvider() followed by CTFontCreateWithGraphicsFont(). Then you'd have a CTFont, which you can draw using Core Text.

据我所知,没有任何方法可以从自定义字体中获取UIFont应用程序包中的字体并使用Info.plist方法(即不下载它),或使用私有API。

As far as I know there's no way to get a UIFont from a custom font without either having the font in your app bundle and using the Info.plist method (i.e. not downloading it), or using private APIs.

这篇关于在iOS中,是否可以在运行时向应用程序添加字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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