Skip to content

varunmehta77/FontAwesome.swift

 
 

Repository files navigation

FontAwesome.swift

Build Status CocoaPods Compatible Carthage Compatible Platform License

Use Font Awesome in your Swift projects

To see the complete set of 675 icons in Font Awesome 4.7.0, please check the FontAwesome.io site.

Installation

Since this is a Swift project, integrating using Carthage is the recommended way. Releases which support CocoaPods might be delayed sometimes.

Carthage

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.

CocoaPods

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.

Manually

  • Drag and drop FontAwesome.otf and all Swift files into your project

Examples

FontAwesome icon in label

label.font = UIFont.fontAwesome(ofSize: 100)
label.text = String.fontAwesomeIcon(name: .github)

FontAwesome icon in label from css class name

label.font = UIFont.fontAwesome(ofSize: 200)
label.text = String.fontAwesomeIcon(code: "fa-github")

FontAwesome icon in button

button.titleLabel?.font = UIFont.fontAwesome(ofSize: 30)
button.setTitle(String.fontAwesomeIcon(name: .github), for: .normal)

FontAwesome icon as navigation bar item

let attributes = [NSFontAttributeName: UIFont.fontAwesome(ofSize: 20)] as [String: Any]
leftBarButton.setTitleTextAttributes(attributes, for: .normal)
leftBarButton.title = String.fontAwesomeIcon(name: .github)

FontAwesome icon as toolbar item

let attributes = [NSFontAttributeName: UIFont.fontAwesome(ofSize: 20)] as [String: Any]
toolbarItem.setTitleTextAttributes(attributes, for: .normal)
toolbarItem.title = String.fontAwesomeIcon(name: .github)

FontAwesome icon as an image

tabBarItem.image = UIImage.fontAwesomeIcon(name: .github, textColor: UIColor.black, size: CGSize(width: 30, height: 30))

FontAwesome icon as an image with background color

tabBarItem.image = UIImage.fontAwesomeIcon(name: .github, textColor: UIColor.blue, size: CGSize(width: 4000, height: 4000), backgroundColor: UIColor.red)

Requirements

iOS 8 or later.

License

  • FontAwesome.otf file licensed under SIL OFL 1.1
  • FontAwesome.swift licensed under MIT

About

Use FontAwesome in your Swift projects

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 95.3%
  • Ruby 3.1%
  • Objective-C 1.6%