iOS Quick Tip: Adding a Custom Font to a Project

Stephen Zaharuk / Friday, May 2, 2014

Apple supports a bunch of fonts, and in each version of iOS it seems like they keep adding more. However, sometimes a custom font gives you that unique look that can help your App stand out from the crowd. Today i'm going to show you how to add your custom font to your project.

1. Drag  your ttf font file into your project. 

2. Within the Project Navigator, select your newly added font file and look over at the Utilities window on the right of xcode. Then make sure "Target Membership" that your application is checked off. 

3. Next we need to tell the application about it. To do that, select the project in the in the Project Navigator. Then make sure your target app is selected and that you're on the Info tab. We'll then add the following Key: "Fonts provided by application" which is of type array. And from there we'll specify our ttf file.

4. Now you're ready to use your font. If you're not sure what your font name would be, you can use the following code to get a listing of all fonts available in your application. If you followed the previous steps correctly, your font will appear in the list:

NSArray* fontFamilies = [UIFont familyNames];
for(NSString* family in fontFamilies)
   NSArray* fonts = [UIFont fontNamesForFamilyName:family];

   for(NSString* fontName in fonts)
      NSLog(@"%@", fontName);

5. If you ran the code above, you should see your font listed in the console of xcode:

6. And now that we know the font name, we can feel free to use it: 

label.font = [UIFont fontWithName:@"BigNoodleTitling" size:20];

Hope this was helpful!

By Stephen Zaharuk (SteveZ)