Latest 1.3.2
Homepage https://github.com/code-troopers/FontAwesome4.swift
License MIT
Platforms ios 8.0, tvos 9.0, requires ARC
Frameworks UIKit, CoreText
Authors ,

Platform
License

Use Font Awesome in your Swift projects

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 "code-troopers/FontAwesome4.swift"

Then add import FontAwesome4 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 'FontAwesome4.swift'

Then, run the following command:

$ pod install

And add import FontAwesome4_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.fontAwesome4(ofSize: 100)
label.text = String.fontAwesome4Icon(name: .github)

FontAwesome icon in label from css class name

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

FontAwesome icon in button

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

FontAwesome icon as navigation bar item

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

FontAwesome icon as toolbar item

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

FontAwesome icon as an image

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

FontAwesome icon as an image with background color

tabBarItem.image = UIImage.fontAwesome4Icon(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

Latest podspec

{
    "name": "FontAwesome4.swift",
    "version": "1.3.2",
    "summary": "Use Font Awesome 4 in your Swift projects, derived from FontAwesome.swift",
    "homepage": "https://github.com/code-troopers/FontAwesome4.swift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Thi Doan": "[email protected]",
        "Cedric Gatay": "[email protected]"
    },
    "source": {
        "git": "https://github.com/code-troopers/FontAwesome4.swift.git",
        "tag": "1.3.2"
    },
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0"
    },
    "requires_arc": true,
    "source_files": "FontAwesome/*.{swift}",
    "resource_bundles": {
        "FontAwesome4.swift": "FontAwesome/*.otf"
    },
    "frameworks": [
        "UIKit",
        "CoreText"
    ]
}

Pin It on Pinterest

Share This