Extensions to use FontAwesome Pro icons in iOS in both Objective-C and Swift.
Note: You must have a FontAwesome 5 Pro license in order for these extensions to work. We do not provide a copy of the icons.
- Download the latest copy of FontAwesome 5 Pro for Web, extract it wherever
- From the
webfonts
directory, copy all of the.ttf
files - (Optional) Remove the weight numbers from the filenames (e.g. fa-brands-400.ttf -> fa-brands.ttf)
- Add the ttf file into your Xcode project
- Ensure that all of the .ttf files are included in the target
- Update your apps info.plist and specify the fonts to include
- Add the source files to your project:
- If using Objective-C: Add
FontAwesome.m
andFontAwesome.h
to your project - If using Swift: Add
FontAwesome.swift
to your project
- If using Objective-C: Add
A (large) enum of all possible icons is available as the FAIcon
type.
- All icons are prefixed with
FA
- Brand icons are also prefixed with
Brands
- Icon variation are suffixed with the variation name, any of
Light
,Regular
,Solid
- Duotone icons are not supported
FAIcon icon = FAPlusCircleLight;
UILabel * label;
label.font = [UIFont fontAwesomeFontForIcon:icon size:label.font.pointSize];
label.text = [NSString fontAwesomeIcon:icon];
let icon = FAIcon.FAPlusCircleLight
let string = icon.string()
let font = icon.font(size: 15.0)
A build script is provided that will generate the enum definition and the implementation.
The build script requires python3.
- From the extracted FontAwesome for web directory, copy the
metadata/icons.json
file to the directory with the build script - Run the build script
python3 build.py
- Copy the enum definition from
enum.h
toFontAwesome.h
- Copy each method in
impl.m
toFontAwesome.m
Software and documentation are provided under MIT. FontAwesome is copyright Fonticons Inc and does not endorse or support this software or documentation.