Use Font Awesome in your Swift projects
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
FontAwesome.otf
and all Swift files into your project
label.font = UIFont.fontAwesome(ofSize: 100)
label.text = String.fontAwesomeIcon(name: .github)
label.font = UIFont.fontAwesome(ofSize: 200)
label.text = String.fontAwesomeIcon(code: "fa-github")
button.titleLabel?.font = UIFont.fontAwesome(ofSize: 30)
button.setTitle(String.fontAwesomeIcon(name: .github), for: .normal)
let attributes = [NSFontAttributeName: UIFont.fontAwesome(ofSize: 20)] as [String: Any]
leftBarButton.setTitleTextAttributes(attributes, for: .normal)
leftBarButton.title = String.fontAwesomeIcon(name: .github)
let attributes = [NSFontAttributeName: UIFont.fontAwesome(ofSize: 20)] as [String: Any]
toolbarItem.setTitleTextAttributes(attributes, for: .normal)
toolbarItem.title = String.fontAwesomeIcon(name: .github)
tabBarItem.image = UIImage.fontAwesomeIcon(name: .github, textColor: UIColor.black, size: CGSize(width: 30, height: 30))
tabBarItem.image = UIImage.fontAwesomeIcon(name: .github, textColor: UIColor.blue, size: CGSize(width: 4000, height: 4000), backgroundColor: UIColor.red)
iOS 8 or later.
- FontAwesome.otf file licensed under SIL OFL 1.1
- FontAwesome.swift licensed under MIT