• Stars
    star
    1,751
  • Rank 26,595 (Top 0.6 %)
  • Language
    Objective-C
  • Created almost 12 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NSString+FontAwesome

FontAwesome+iOS

Font awesome is an iconic font. Read more about it on http://fortawesome.github.com/Font-Awesome/

This category brings this great iconic font on iOS.

Usage

First, make sure you have FontAwesome.ttf bundled in your project and that UIAppFonts key in the project's plist file contains a String item named FontAwesome.ttf Then add the NSString+FontAwesome category to the project.

UILabel *label = [...]
label.font = [UIFont fontWithName:kFontAwesomeFamilyName size:20];

You can now use enums for all the different iconic characters

label.text = [NSString fontAwesomeIconStringForEnum:FAGithub];

or you can reference them by using the class identifiers listed here http://fortawesome.github.io/Font-Awesome/icons

label.text = [NSString fontAwesomeIconStringForIconIdentifier:@"fa-github"];

or you can add the UIImage+FontAwesome category to generate icon image directly

UIImage *github = [UIImage imageWithIcon:@"fa-github" backgroundColor:[UIColor purpleColor] iconColor:[UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:255] iconScale:2.f fontSize:20];

then you will get an icon like this

image

That's all.
Have a look at the small demo project for further information.

FAImageView

FAImageView is now extended and contains a new property called defaultView that is shown when the image is set to nil. It is possible to use one the font-awesome icon as a default placeholder for an image view.

FAImageView *imageView = [[FAImageView alloc] initWithFrame:CGRectMake(0.f, 0.f, 100.f, 100.f)];
imageView.image = nil;
[imageView setDefaultIconIdentifier:@"fa-github"];

Troubleshooting

Some icons are not available on some devices

Keep in mind that if you have installed the FontAwesome font in your iOS system (with InstaFont for example), the embedded font in your App will not be used! So if your system FontAwesome font is v4.2, you will never be able to display icons from v4.3 and v4.4 for example from the embedded font.

Two solutions :

  1. Remove the font profile from your iOS device
  2. Rename the Postscript name of file FontAwesome.ttf with a tool like ttx for example and use the new name in NSString+FontAwesome.h

Here is the step by step for second solution :

  • Install fonttools

    git clone https://github.com/behdad/fonttools.git ;
    cd fonttools/
    sudo python setup.py install
    
  • Convert the FontAwesome.ttf file to ttx format

    cd your_app/Pods/FontAwesome+iOS/Resources/
    ttx FontAwesome.ttf
    
  • Replace all occurence of FontAwesome with FontAwesome440 for example in ttx file and save

  • Convert back ttx font to ttf

    ttx FontAwesome.ttx
    mv FontAwesome.ttf FontAwesome.ttf.orig
    mv FontAwesome#1.ttf FontAwesome.ttf
    
  • In file NSString+FontAwesome.h, change font Postscript name :

    static NSString *const kFontAwesomeFamilyName = @"FontAwesome440";
    
  • Build, run and dance

License

This project uses the FontAwesome fix made by Pit Garbe that you can find at https://github.com/leberwurstsaft/FontAwesome-for-iOS Version 2.0 of the Font Awesome font, CSS, and LESS files are licensed under CC BY 3.0: http://creativecommons.org/licenses/by/3.0/ A mention of 'Font Awesome - http://fortawesome.github.com/Font-Awesome' in human-readable source code is considered acceptable attribution (most common on the web). If human readable source code is not available to the end user, a mention in an 'About' or 'Credits' screen is considered acceptable (most common in desktop or mobile software)

More Repositories

1

Render

UIKit a-lΓ  SwiftUI.framework [min deployment target iOS10]
Swift
2,157
star
2

ios-realtimeblur

Multipurpose real-time blur view for iOS6+
Objective-C
956
star
3

Store

Unidirectional, transactional, operation-based Store implementation.
Swift
502
star
4

flexboxobjc_deprecated

A simple UIKit extension to wrap Flexbox layouts.
Objective-C
398
star
5

Buffer

Swift ΞΌ-framework for efficient array diffs and datasource adapters.
Swift
349
star
6

flexboxswfit_deprecated

(Deprecated) Port of Facebook's css-layout to Swift
Swift
307
star
7

DataStructures

A collection of Data Structures implemented in Swift.
Swift
48
star
8

Primer

Assign/Partial/ReadOnly/Proxy/Locks in Swift
Swift
32
star
9

CoreRender

Moved to https://github.com/alexdrone/Render
Objective-C++
26
star
10

S.swift

Get strong typed, autocompleted resources, color swatches and font styles in Swift projects from a simple YAML stylesheet.
Swift
25
star
11

YAS

Yet Another Stylesheet (YAML-based Stylesheet Engine)
Swift
23
star
12

Surface

A set of utilities and extensions to create depth in your views by using complex shadows.
Swift
18
star
13

PushID

Robust and thread-safe generator for uuids with guaranteed chronological ordering in Swift.
Swift
16
star
14

Emit

Event propagation and object observation library (Pre-Combine.framework).
Swift
10
star
15

ObjCTrait

Trait support for Objective-C
Objective-C
9
star
16

PatchComposer

A Quartz-composer like UI for patch editing in SwiftUI
Swift
8
star
17

SwiftUI_UIKit_Bridge

Share custom typography and color swatches between UIKit and SwiftUI.
Swift
6
star
18

Pbtxt

Schemaless protobuf text-format parser (with Codable support).
Swift
5
star
19

itu_pku_eventregexp

Java
5
star
20

GuruMeditation

Nostalgic error screen for iOS.
Swift
4
star
21

DesignSystemTemplate

A customizable design system in Swift.
Swift
4
star
22

Multipeer

Forked from: https://github.com/insidegui/MultipeerKit
Swift
3
star
23

ui_dsl_deprecated

(Deprecated) A lightweight native stylesheet engine for iOS
Objective-C
3
star
24

cxx_tutorials

A bunch of tutorials used to teach modern C++ and OpenGL to iOS devs
C++
3
star
25

Multi.kt

Kotlin Multiplatform Lib Template
Kotlin
3
star
26

swift1_rune_game

An iOS game inspired by 'Dots' based on the nordic runes
Objective-C
2
star
27

firebase_utils_deprecated

Firebase-backed store for Dispatch
Swift
2
star
28

trn_modelmapper

A ORM inspired by Ruby's DataMapper and ActiveRecord
Java
2
star
29

yaHN-android

Yet another HackerNews Android client
Java
2
star
30

FontCustom

fontcustom template for iOS
Objective-C
2
star
31

itu_algorithms

Some algorithms back from Uni time
Ruby
2
star
32

objc_latte_uikit_deprecated

(deprecated) An iOS markup language, framework and tool to help the design and the implementation of the presentation layer.
1
star