Using Custom Fonts

In your iOS application you can import and use custom fonts. In this tutorial we will create a UILabel with some sample text and set the font to our custom font.

Open Xcode and create a new Single View Application. For product name, use CustomFontDemo and then fill out the Organization Name, Company Identifier and Class Prefix fields with your customary values. Make sure only iPhone is selected in Devices, and that the Use Storyboards checkbox is deselected and Use Automatic Reference Counting checkbox is selected.

First, Let's create our User Interface. Go to ViewController.xib. Drag a Label to the main View. The main View should look like this.

In ViewController.m in the interface section declare the following properties.

@interface ViewController ()

@property (nonatomic, strong) IBOutlet UILabel *textLabel;


Go back to ViewController.xib. Select the Assistant Editor. On the right side select ViewController.m. Ctrl-click and drag from the Label to the IBOutlet textLabel property in ViewController.m.

Now, it's time to import the font file to the project and open the Info.plist file.

  • Add a Array to your CustomFontDemo-info.plist file called "Fonts provided by application"
  • Enter the full name of your font file i.e. wakingup.ttf (including the extension) as items to the array

The plist file should look like this.

Change the viewDidLoad method to

- (void)viewDidLoad
[super viewDidLoad];

[self.textLabel setFont: [UIFont fontWithName: @"WakingUp" size:48]];
self.textLabel.text = @"Custom Font Demo";

Build and Run.

You can download the source code of the CustomFontDemo at the ioscreator repository on github.