In iOS, Is it possible to add a font to the app during runtime?

隐身守侯 提交于 2019-12-01 09:08:22

问题


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.

Please help


回答1:


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

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.



来源:https://stackoverflow.com/questions/9821211/in-ios-is-it-possible-to-add-a-font-to-the-app-during-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!