Custom Font in ios not working

前端 未结 17 1920
北海茫月
北海茫月 2020-12-07 22:53

I want to use HelveticaNeue-UltraLight in my ios application. I\'m adding the font file as a resource to my project and adding the \"Fonts provided by application\" key in t

17条回答
  •  庸人自扰
    2020-12-07 23:04

    After spending hours, I came to know that the Name for the font we need to add is not the file name of the font but the actual Font name. I was trying to include font file bonveno.ttf. I have included the filename along with extension in info.plist and was able to see the font in the Copy Bundle Resources list. My code was like

    self.label.font = [UIFont fontWithName:@"bonveno" size:30];
    

    that was causing the problem. Then I double clicked the font file from Finder to see the preview of the font. That time I noticed the name of the font in the preview window as BonvenoCF. So I added that name in the code like

    self.label.font = [UIFont fontWithName:@"BonvenoCF" size:30];
    

    Worked like charm!! Can't live without this cute font in my apps.

提交回复
热议问题