How to integrate and use Font Awesome with Objective-C or Swift in an Xcode project?
In Swift:
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 = 0xF180label.text = String(format: "%C", myChar)self.view.addSubview(label)
BEST solution for FA with XCode:
- Copy the icon you want from http://fontawesome.io/cheatsheet/ (I mean mark and copy the icon itself):
- Then add a label to your storyboard, and on its properties:
- RED - Choose FontAwesome as family
- GREEN - Set the size you want
- BLUE - Paste here what you copied in the 1st step. (dont worry about the question mark - in the view you should see it properly).
That's it.
If you need to change the icon in the code - you can paste 1st step inside your code too:
Not sure you ever got this working properly, but there's now a couple of nice projects on github:
https://github.com/alexdrone/ios-fontawesome - which gives you a category for NSString which offers basic help using FontAwesome.
and https://github.com/leberwurstsaft/FontAwesome-for-iOS which gives you a NSString category with fontAwesomeIconStringForIconIdentifier
and also an UIImageView
subclass: FAImageView