• Stars
    star
    257
  • Rank 158,728 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 10 years ago
  • Updated almost 10 years ago

Reviews

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

Repository Details

Speedup your iOS app development using icon fonts

Stencils

Build Status Stories in Ready Pod Version Pod Version

Speedup your iOS app development using icon fonts!

Icon fonts are very popular in the web development world. And they are awesome. With Stencils you can now access the power and awesomeness of icon fonts in the development of your iOS app, and save a lot of emails with the designer to get the new asset with the shadow 0.5 point more to the left and 3.141592% less opaque.

Install

Via CocoaPods.

pod 'Stencils'

or

pod 'Stencils', ~> 'x.x.x'

where x.x.x is the version number you want. Latest stable is Pod Version

Usage

Three simple steps:

1. Add your icon font file to the project

Just add the .ttf to the project. No Info.plist update needed! And you can even add multiple icon fonts.

2. Define your icons

Stencils needs to know how to read the font file. Create a configuration file, by default Stencils will look for Stencils.plist, in this fashion:

font-icons	Array
	Item 0	Dictionary
		font-name				String	The name of the font where the icon is located
		icon-name				String	The name to use to load the icon
		icon-code				String	The unicode caracter corresponding to the icon
										i.e: e001
		baseline-adjustement	Number	(Optional) A correction value to compensate eventual offset from the baseline
		scale-adjustement		Number	(Optional) A correction value to change the scale of the icon. Usually used with "baseline-adjustement"

Have a look at the example projects to see how a real configurations plist looks like.

3. Load icons using STIconsFactory and STIconView

#import <STIconsFactory.h>

STIconsFactory *factory = [[STIconsFactory alloc] init];
STIconView *arrow = [factory iconViewForIconNamed:@"arrow-left" withSide:60.0f];

You can customize your icon like this:

arrow.backgroundColor = [UIColor whiteColor];
arrow.color = [UIColor blackColor];
// If no color is set the icon will use the tintColor of its superview
arrow.shadowColor = [UIColor grayColor];
arrow.shadowOffset = CGSizeMake(1.0f, 1.0f);

Tuning the icons metrics

It can happen that the icons are rendered cropped. This is due to the original font metrics not being as iOS would like them. baseline-adjustement and scale-adjustement are there to compensate this issue.

To help you fine tune those values there's the IconSettings app from this repo. You can load your raw .plist, launch it on a device, tune each icon, then email yourself the tuned .plist. It's a rather sub-optimal approach, but... it works.

.plist generator script

Use the experimental plist_generator.rb script located in the Scripts folder to generate the Stencils.plist to import together with the .ttf font in your app from the .css that you would use for the webfont.

Run plist_generator.rb --help

Important note: the script is experimental, that is I cannot guarantee it's gonna work 100% of the times. I tried it only on the css files that IcoMoon and Fontello generate.

Where to find icons fonts

Contribute

  1. Fork the repo
  2. Checkout a new branch username/feature_name
  3. Open a Pull Request

===

Made with β™₯ by @mokagio. Special thanks to @tancdev.

More Repositories

1

UICollectionViewLeftAlignedLayout

A layout for UICollectionView that aligns the cells to the left.
Objective-C
1,293
star
2

UIColor-FlatColors

A category to extend UIColor with the flat colors from the Flat UI framework
Objective-C
209
star
3

UICollectionViewRightAlignedLayout

A layout for UICollectionView that aligns the cells to the right.
Objective-C
168
star
4

Swift-Koans

Learn Swift by making tests pass
Swift
29
star
5

DDAntennaLogger

A custom CocoaLumberjack logger for remote logging through Antenna
Objective-C
26
star
6

UIColor-CSSColors

Extend UIColor with CSS colors
Objective-C
26
star
7

MTFontIcon

Checkout Stencils, MTFontIcon evolution.
Objective-C
11
star
8

dotfiles

My dotfiles
Shell
10
star
9

mokacoding-samples

Repo with the example projects from http://www.mokacoding.com/
Objective-C
7
star
10

Shortcuts

Learning a new shortcut every day βŒ¨οΈπŸ“ˆ
7
star
11

CombineTestHelpers

Custom XCTest assertions for Combine types
Swift
6
star
12

Swift-Functor-Introduction-Playground

A playground to introduce Functors in Swift, and their practical usage. From my Melbour CocoaHeads #85 lighting talk.
Swift
6
star
13

ReadingList

Swift
5
star
14

TestingCombineExamples

Swift
5
star
15

mokacoding

Repo for mokacoding, my personal coding blog
CSS
5
star
16

swift-tdd-exercises

Swift
4
star
17

CircularButtons

Easy to use and configure circular UIButton with icons
Swift
4
star
18

tmnt-gifs

A shell shocked Slack slash command showing Teenage Mutant Ninja Turtles gifs
Ruby
4
star
19

yow-connected-2015

Playground from my talk at YOW! Connected 2015
Swift
4
star
20

RemoteData

Swift port of Elm's RemoteData package.
Swift
4
star
21

forget-me-not

A smart, contextualised todo list. Designed to live in your terminal, and to be in your face.
Ruby
3
star
22

Unless.swift

Unless this do that
Swift
3
star
23

metallo.js

A draft of ready made blog made with metalsmith
JavaScript
3
star
24

the-unit-testing-library

Books on unit testing
3
star
25

MGSpriteView

A UIView subclass to play animation using a sprite sheet.
Objective-C
2
star
26

GenericTableViewController

Swift
2
star
27

TweaksBuildConfigurationsDemo

A demo of an unexpected behaviour of Tweaks by Facebook
Objective-C
2
star
28

MGCraftman

A framework to speedup development when you can't (or don't want to) use Interface Builder
Objective-C
2
star
29

MinimalNetworking

Swift
2
star
30

ios-deploy-gem

A gem mirroring the ios-deploy node package
Ruby
2
star
31

cli-pods

How to use CocoaPods to install CLI tools, and GitHub actions to cache them
Ruby
2
star
32

learn-you-a-haskell

My notes from reading "Learn You a Haskell fro Great Good!"
Haskell
2
star
33

tddinswift_fake_api

2
star
34

Navigation-Delegate-Example

Swift
1
star
35

MGInsetLabel

A super simple UILabel subclass that adds configurable insets
Objective-C
1
star
36

repo_analyzer

Ruby
1
star
37

removing-duplications-in-swift-examples

Swift
1
star
38

DateFactory

An n-framework for creating NSDate in your unit tests.
Swift
1
star
39

TestingSwiftResult

Examples on how to test Swift Result
Swift
1
star
40

gifs

1
star
41

SwiftUI-Xcode-Template

Swift
1
star
42

XCTOverview

Swift
1
star
43

KeyboardAnimationSubscriber

Swift
1
star
44

SwiftUItoUIKit

Swift
1
star
45

zsh-mokagio-aliases

My aliases on zsh
Shell
1
star
46

not-a-journal

Not a journal blog, but a scrapbook for ideas and reflections
Shell
1
star
47

xceasy

Experimenting with Swift CLIs
Swift
1
star
48

Catipedia-iOS

The Great Memrise Thessaloniki Hackathon - Catipedia - iOS Project
Objective-C
1
star
49

PizzaDelivery

Swift
1
star
50

github-action-milestone-workflow-example

1
star
51

SpaceX

Swift
1
star
52

devworld2015

Playground from my talk at /dev/world/2015
1
star
53

continuous-improvement-journal

HTML
1
star
54

swift-tdd-workshop

1
star
55

justninegags

Learning Project - A 9GAG reader that shows only 9 gags per hour. Also wrote a blog post about it.
Objective-C
1
star
56

MGIOUtils

A small set of utils to make file operations on iOS simpler
Objective-C
1
star
57

swift-collection-if-in-bounds

Micro-Swift Package to add a subscript operator to Collection types (like Array) that returns Optional.none if there is no element at the given index instead of crashing.
Swift
1
star