Git Product home page Git Product logo

fontawesomeswift's Introduction

Build Status Cocoapods Version Swift Xcode Platform License

FontAwesomeSwift

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.

fontawesomeswift's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.