Latest 1.8.1
Homepage https://github.com/charles-oder/FontAwesomeSwift
License MIT
Platforms ios 8.0
Authors

Build Status
Cocoapods Version
Swift
Xcode
Platform
License

Icon Font library for iOS.

Installation

Requirements

  • Xcode 7+
  • iOS 8.0+
  • Swift 3.0+ or Objective-C

Install with Cocoapods

Add pod 'FontAwesomeSwift' to Podfile

Or use subspecs to include only certain fonts

pod 'FontAwesomeSwift/FontAwesome'

pod 'FontAwesomeSwift/Ionicons'

pod 'FontAwesomeSwift/FoundationIcons'

pod 'FontAwesomeSwift/MaterialDesign'

pod 'FontAwesomeSwift/Octicons'

pod 'FontAwesomeSwift/Zocial'

Run pod install or pod update

Usage

Importing

Swift

import FontAwesomeSwift

Objective-C

#import <FontAwesomeSwift/FontAwesomeSwift-Swift.h>

Creating an icon

Swift

let icon: FASIcon = FASIonicons().checkmarkRoundIcon(size: 20)
let anotherIcon: FASIcon? = FASIonicons().icon(name: "ion-checkmark", size: 20)
let anotherIconFromCode: FASIcon = FASIonicons().icon(name: "u{f122}", size: 20)
let greenIcon: FASIcon = FASIonicons().checkmarkRoundIcon(size: 20).color(color: UIColor.green)
let greenIconImage: UIImage? = FASIonicons().checkmarkRoundIcon(size: 20).color(color: UIColor.green).image
let greenIconAttributedString: NSAttributedString = FASIonicons().checkmarkRoundIcon(size: 20).color(color: UIColor.green).attributedString 
let iconImageWithGreenBackground: UIImage? = FASIonicons().checkmarkRoundIcon(size: 20).backgroundColor(color: UIColor.green).image
let paddedIconImage: UIImage? = FASIonicons().checkmarkRoundIcon(size: 20).padding(padding: 10).image
let offsetIconImage: UIImage? = FASIonicons().checkmarkRoundIcon(size: 20).offset(x: 20, y: 20).image

Objective-C

FASIcon *icon = [[FASIonicons new] iosInformationOutlineIconWithSize:20];
FASIcon *anotherIcon = [[FASIonicons new] iconWithName: @"ion-checkmark" size:20];
FASIcon *anotherIconFromCode = [[FASIonicons new] iconWithCode: @"uf122" size:20];
FASIcon *greenIcon = [[[FASIonicons new] iosInformationOutlineIconWithSize:20] colorWithColor:[UIColor greenColor]];
UIImage *greenIconImage = [[[FASIonicons new] iosInformationOutlineIconWithSize:20] colorWithColor:[UIColor greenColor]].image;
NSAttributedString *greenIconAttributedString = [[[FASIonicons new] iosInformationOutlineIconWithSize:20] colorWithColor:[UIColor greenColor]].attributedString;
UIImage *greenBackgroundImage = [[[FASIonicons new] iosInformationOutlineIconWithSize:20] backgroundColorWithColor:[UIColor greenColor]].image;
UIImage *paddedIconImage = [[[FASIonicons new] iosInformationOutlineIconWithSize:20] paddingWithPadding: 10].image;
UIImage *offsetIconImage = [[[FASIonicons new] iosInformationOutlineIconWithSize:20] offsetWithX: 20 y: 20].image;

Adding Custom Fonts

Custom font files may be added to a project by overriding the FASFont class
and declaring the font family and type with the factory override properties:
fontType and fontFamily.

If the font file name is different than the family name, the fontFileName property may be overridden to declare that.

The framework will search the bundle that the overridden FASFont class is associated with.
The bundle property may be overridden if the font file is in a different bundle.

Example

 public class CustomFont: FASFont {

    public override var fontFamily: String {
        return "CustomFontFamily"
    }

    public override var fontType: String {
        return "ttf"
    }

    public override var fontFileName: String {
        return "CustomFontFile"
    }

    public func customFontMethod(size: CGFloat) -> FASIcon {
        return FASIcon(font: font(size: size), iconCode: "u{0001}")
    }

}

Mapping Names to Font Codes

Overriding the allIcons property with a [name : code] mapping wil allow client code to create font icons with the icon(name: String, size: CGFloat) method.

Latest podspec

{
    "name": "FontAwesomeSwift",
    "version": "1.8.1",
    "summary": "FontAwesome in Swift",
    "swift_version": "4.2",
    "description": "An extensible library for using external font icons such as FontAwesome.",
    "homepage": "https://github.com/charles-oder/FontAwesomeSwift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Charles Oder": "[email protected]"
    },
    "source": {
        "git": "https://github.com/charles-oder/FontAwesomeSwift.git",
        "tag": "1.8.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": [
        "FontAwesomeSwift/FontAwesomeSwift.h",
        "FontAwesomeSwift/LICENSE"
    ],
    "subspecs": [
        {
            "name": "Core",
            "source_files": "FontAwesomeSwift/Core/*"
        },
        {
            "name": "FontAwesome",
            "dependencies": {
                "FontAwesomeSwift/Core": []
            },
            "source_files": "FontAwesomeSwift/FontAwesome/*.swift",
            "resources": "FontAwesomeSwift/FontAwesome/Resources/*.ttf"
        },
        {
            "name": "Ionicons",
            "dependencies": {
                "FontAwesomeSwift/Core": []
            },
            "source_files": "FontAwesomeSwift/Ionicons/*.swift",
            "resources": "FontAwesomeSwift/Ionicons/Resources/*.ttf"
        },
        {
            "name": "FoundationIcons",
            "dependencies": {
                "FontAwesomeSwift/Core": []
            },
            "source_files": "FontAwesomeSwift/FoundationIcons/*.swift",
            "resources": "FontAwesomeSwift/FoundationIcons/Resources/*.ttf"
        },
        {
            "name": "MaterialDesign",
            "dependencies": {
                "FontAwesomeSwift/Core": []
            },
            "source_files": "FontAwesomeSwift/MaterialDesign/*.swift",
            "resources": "FontAwesomeSwift/MaterialDesign/Resources/*.ttf"
        },
        {
            "name": "Octicons",
            "dependencies": {
                "FontAwesomeSwift/Core": []
            },
            "source_files": "FontAwesomeSwift/Octicons/*.swift",
            "resources": "FontAwesomeSwift/Octicons/Resources/*.ttf"
        },
        {
            "name": "Zocial",
            "dependencies": {
                "FontAwesomeSwift/Core": []
            },
            "source_files": "FontAwesomeSwift/Zocial/*.swift",
            "resources": "FontAwesomeSwift/Zocial/Resources/*.ttf"
        }
    ]
}

Pin It on Pinterest

Share This