Search code examples
iosuifontios8-today-widget

Custom font iOS in Today Widget always return nil


I was trying to add custom font to my today extension but UIFont always return nil.

Steps:

  1. I added the font file to Today Widget target:

enter image description here

  1. I check if the font file was inside the Today Widget bundle:

enter image description here

  1. I init the font instance in the TodayViewController of Today Widget but it always return nil:
- (void)viewDidLoad {
    [super viewDidLoad];
    UIFont* ft = [UIFont fontWithName:@"octicons-local" size:20];
}

enter image description here

I used the same method in my main project, and I can get the custom font. How can I fix it?


Solution

  • Maybe it's because you forgot to add key in your .plist file.

    Add the key Fonts provided by application to a new row. Add items for each font you have added.