Use Font Awesome in your Swift projects
To see the complete set of 3,652 icons in Font Awesome 5, please check the FontAwesome.com site.
Since this is a Swift project, integrating using Carthage is the recommended way. Releases which support CocoaPods might be delayed sometimes.
To integrate FontAwesome into your Xcode project using Carthage, specify it in your Cartfile
:
github "thii/FontAwesome.swift"
Then add import FontAwesome
to the top of the files using FontAwesome.
To integrate FontAwesome into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'FontAwesome.swift'
Then, run the following command:
$ pod install
And add import FontAwesome_swift
to the top of the files using FontAwesome.
- Drag and drop all
.otf
and.swift
files into your project
// FontAwesome icon in label
label.font = UIFont.fontAwesome(ofSize: 100, style: .brands)
label.text = String.fontAwesomeIcon(name: .github)
let attributes = [NSAttributedStringKey.font: UIFont.fontAwesome(ofSize: 20, style: .brands)]
// FontAwesome icon in button
button.titleLabel?.font = UIFont.fontAwesome(ofSize: 30, style: .brands)
button.setTitle(String.fontAwesomeIcon(name: .github), for: .normal)
// FontAwesome icon as navigation bar item
barButton.setTitleTextAttributes(attributes, for: .normal)
barButton.title = String.fontAwesomeIcon(name: .github)
// FontAwesome icon as toolbar item
toolbarItem.setTitleTextAttributes(attributes, for: .normal)
toolbarItem.title = String.fontAwesomeIcon(name: .github)
// FontAwesome icon as image
imageView.image = UIImage.fontAwesomeIcon(name: .github, style: .brands, textColor: .black, size: CGSize(width: 4000, height: 4000))
// FontAwesome icon as image with background color
imageViewColored.image = UIImage.fontAwesomeIcon(name: .github, style: .brands, textColor: .white, size: CGSize(width: 4000, height: 4000), backgroundColor: .black)
iOS 8 or later.
To update this project to include all the latest icons:
cd FortAwesome/Font-Awesome
git fetch origin
git checkout 5.3.0 # Replace with the latest released version
cd ../.. # Go back the project root
./codegen.swift # Re-generate Enum.swift file from the latest icon list
- All font files licensed under SIL OFL 1.1
- FontAwesome.swift licensed under MIT