How to integrate and use Font Awesome with Objective-C or Swift in an Xcode project?

adit picture adit · May 13, 2012 · Viewed 34.1k times · Source

So I am trying to use this font http://fortawesome.github.com/Font-Awesome/. I've added the font as a resource and put it in the plist file. Here's how I am using it:

[homeFeedButton.titleLabel setFont:[UIFont fontWithName:@"fontawesome" size:8]];
NSString *str = [NSString stringWithFormat:@"%C", @"\f030"];

However this doesn't work. Does anyone know how to use this font in an Xcode project?

Answer

King-Wizard picture King-Wizard · Jun 15, 2015

In Swift:

Font Awesome Cheatsheet.

Tutorial on how to integrate the font called "Font Awesome" in your Xcode project.

Common Mistakes With Adding Custom Fonts to Your iOS App

let label = UILabel(frame: CGRectMake(0, 0, 100, 100))
label.font = UIFont(name: "FontAwesome", size: 40)
let myChar: UniChar = 0xF180
label.text = String(format: "%C", myChar)
self.view.addSubview(label)