Dynamic custom fonts loader in iOS

前端 未结 3 1278
陌清茗
陌清茗 2020-12-29 00:23

i already know how to load a custom font to my project in iPhone App from here I want to ask if there is a way to do this from code? My problem is that I have a resource fol

3条回答
  •  生来不讨喜
    2020-12-29 01:14

    Yes you can. But you've to work a lot with CoreText and/or CoreGraphics.

    There's a nice class from Zynga that could help you in doing this: https://github.com/zynga/FontLabel

    The example project shows how to load .ttf files from the bundle without using the .plist and use these fonts inside the application.

    The code is valid and is a good point from start.

    Edit: The previous approach uses CoreGraphics, that is good, but use Core Text is much better. I found an interesting answer to this question: How can you load a font (TTF) from a file using Core Text?

    If you don't have experience with CoreText framework, please read the official introduction inside the Apple documentation.

提交回复
热议问题