TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Custom |
ReleasedLast Release | Apr 2015 |
Maintained by Jeremy Anticouni.
Font awesome is, well, awesome. If you don't know about it, go here, we'll wait.
This category makes it drop-dead simple to use in iOS.
First, you'll need to tell Xcode that you want to include the FontAwesome font. the font file and add it to your Xcode project.
fontawesome-webfont.ttf
.Info.plist
, look for Fonts provided by application
or UIAppFonts
. If it doesn't exist, add it, making sure that it is an array
.UIAppFonts
array: fontawesome-webfont.ttf
.Next, assuming CocoaPods is already installed, simply add JAFontAwesome to your podfile and then run pod update
:
pod 'JAFontAwesome'
If you need to install CocoaPods, go here.
Finally, add the NSString+FontAwesome
category to the project:
#import "NSString+FontAwesome.h"
First, let's create a label and define the size and font:
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
label.font = [UIFont fontWithName:kFontAwesomeFamilyName size:20];
Now, we can use enums to display an icon..
label.text = [NSString fontAwesomeIconStringForEnum:FAGithub];
..or you can reference them by using the class identifiers listed here, like so:
label.text = [NSString fontAwesomeIconStringForIconIdentifier:@"fa-github"];
Enjoy!
Originally forked from Alex Drone's ios-fontawesome and uses the String+FontAwesome.swift addition from Riz. This project also uses the FontAwesome fix made by Pit Garbe.
A mention of 'Font Awesome - http://fortawesome.github.com/Font-Awesome' in human-readable source code is considered acceptable attribution (most common on the web). If human readable source code is not available to the end user, a mention in an 'About' or 'Credits' screen is considered acceptable (most common in desktop or mobile software.)