Can't use custom font in iOS app

前端 未结 6 768
不知归路
不知归路 2021-01-03 10:55

I\'m trying to use custom font for my iOS app. Here is what I do

I added my custom font (m.tff) to Xcode Supporting files directory. Also I create entry called Fonts

6条回答
  •  执念已碎
    2021-01-03 11:38

    In your Info.plist file, add the key: Fonts provided by application with an array object, and set the items of the array to strings as follows:

    MyFont.ttf
    

    Where MyFont is the EXACT name as listed for the font in your Mac's app, "Font Book." Use Spotlight to launch font book and then find your font file in there to double check the name.

    Then when you set the font to your label:

    myLabel.font = [UIFont fontWithName: @"MyFont" size: someFloatValue];
    

提交回复
热议问题