Unable to set custom font for the UILabel in XCode

2020-06-04 12:19发布

I am unable to set custom font for the UILabel in XCode.

This is what I've tried:

  • Download "JennaSue" font -- http://www.dafont.com/jenna-sue.font

  • Open "app-info.plist" under "Supporting Files" folder

  • Add new row in the list with key "Fonts provided by application"

  • In this array add "JennaSue.ttf"

  • Use it in the code like this:

self.someLabel.font = [UIFont fontWithName:@"JennaSue" size:14];

And nothing happens -- the default font is visible.

Why? What am I doing wrong? How can I fix it?

9条回答
smile是对你的礼貌
2楼-- · 2020-06-04 13:08

i used following code and it's done

 UILabel * lblTest = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 200, 100)];

    lblTest.font = [UIFont fontWithName:@"JennaSue" size:25.0];
    lblTest.text = @"Hello World";

    [self.view addSubview:lblTest];

and if still not working looking at your system font book and search that font and That Font you have to use to get it work

also try this lblTest.font = [UIFont fontWithName:@"Jenna Sue" size:25.0];

查看更多
霸刀☆藐视天下
3楼-- · 2020-06-04 13:09
self.someLabel.font = [UIFont fontWithName:@"JennaSue.ttf" size:self.someLabel.font.pointSize];
查看更多
4楼-- · 2020-06-04 13:11

The font could be corrupted or something. I tried the solutions provided by Gabriel.Massana & Neeku and it worked on some fonts. Try adding the font to your Mac. If it showed verification problem, most probably it's not gonna work in your app. Hope this helps

查看更多
登录 后发表回答