• This repository has been archived on 24/Jun/2022
  • Stars
    star
    1,577
  • Rank 29,672 (Top 0.6 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

🎨 Auto-generated icon font library for iOS, watchOS and tvOS

This library is no longer maintained due to underlying issues.


Iconic Header

Travis codecov Pod Version Pod Platforms Swift Version License

Iconic helps making icon fonts integration effortless on iOS, tvOS and watchOS. Its main component is in charge of auto-generating strongly typed Swift code with SwiftGen, compatible with Objective-C.

You will interact with an auto-generated class under the name of {FontName}Icon.swift, which is a light abstraction of the IconDrawable.swift protocol. For more information, have a look at how to install and how to use.

Give Iconic a test drive by simply doing pod try Iconic in your terminal, and pick the Samples.xcworkspace.

Scale Example

Why Icon Fonts?

  • Resolution independent: scale and tint without quality loss
  • Automatically scaled for different screen densities
  • Work with (way) less image files
  • Improve visual consistency
  • Platform agnostic
  • Add better UI accessibility
  • Simple to work with

Where can I find awesome icon fonts?

Key Features

Note: Some open sourced icon fonts don't include the names of each of their glyphs. This could result in a non-descriptive enums, which can make things less intuitive for you when using Iconic. If you create your own icon font, make sure to properly name each glyph.

Installation

Via CocoaPods

Start by defining Iconic on your Podfile. Because we use an environment variable on a non-traditional setup, you will need to do it the following way:

pod 'Iconic', :git => 'https://github.com/home-assistant/Iconic.git', :tag => '1.3'

To install Iconic with a custom icon font, you need to use the FONT_PATH environment variable:

FONT_PATH='/Users/WillFerrell/Desktop/super-duper-font.otf' pod install

FONT_PATH='/Users/WillFerrell/Desktop/super-duper-font.otf' pod update Iconic

If you simply call pod install, Iconic will be installed using its default font, FontAwesome.

After the installation is complete, you should see 3 files: IconDrawable.swift, the auto-generated {FontName}Icon.swift and the font file added as a resource: Pod Setup

How to use

For complete documentation, visit Iconic's docs.

Import

Import the Iconic module:

Swift
import Iconic
Objective-C
@import Iconic;

Registering the icon font

Registration is required to activate Iconic. You shall do this once, when launching your application. Internally, the icon mapping is retrieved and kept in memory during the application's life term.

Iconic provides a convenient way to register the icon font: Note: the method name may change depending of your icon font's name:

Swift
FontAwesomeIcon.register()
Objective-C
[Iconic registerFontAwesomeIcon];

Use as images

You can construct an UIImage instance out of a font's icon and tint it. This may be very convenient for integrating with existing UIKit controls which expect UIImage objects already.

Images are created using NSStringDraw APIs to render a UIImage out of an NSAttributedString.

Swift
let size = CGSize(width: 20, height: 20)

let icon = FontAwesomeIcon.HomeIcon
let image = icon.image(ofSize: size, color: .blue)
Objective-C
[Iconic imageWithIcon:FontAwesomeIconHomeIcon size:CGSizeMake(20, 20) color:[UIColor blueColor]];

Use as attributed strings

You may need to icons as text too, and simplify your layout work. For example, instead of having an image and a label, you can combined it all in one single label:

Swift
let icon = FontAwesomeIcon.HomeIcon
let iconString = icon.attributedString(ofSize: 20, color: .blue)
Objective-C
[Iconic attributedStringWithIcon:FontAwesomeIconHomeIcon pointSize:20.0 color:[UIColor blueColor]];

Use as unicode string

Ultimately, you may need to retrieve the unicode string representation on an icon to do more advanced things:

Swift
let unicode = FontAwesomeIcon.HomeIcon.unicode

Use as font

For further customization, you may need to use the UIFont object instead:

Swift
let font = FontAwesomeIcon.font(ofSize: 20)
Objective-C
UIFont *font = [Iconic fontAwesomeIconFontOfSize:20.0];

Interface Builder Support

Interface Builder

Iconic includes a UIImageView subclass under the name of {FontName}IconView.swift, conforming to @IBInspectable. This class allows IB integration with little effort:

  • Use the iconName attribute to set the icon on Interface Builder (use the icon font html catalog as reference for icon names).
  • Adjust the bounds of the view to see it dynamically adjust the icon size.

UIKit Extensions

UIKit extensions are also included, just to make your code look simpler:

Swift
// UITarbBarItem
UITabBarItem(withIcon: .BookIcon, size: CGSize(width: 20, height: 20), title: "Catalog")

// UIBarButtonItem
UIBarButtonItem(withIcon: .BookIcon, size: CGSize(width: 24, height: 24), target: self, action: #selector(didTapButton))

// UIButton
let button = UIButton(type: .System)
button.setIconImage(icon: .HeartIcon, size: CGSize(width: 44, height: 44), color: nil, forState: .Normal)
Objective-C
// UITarbBarItem
[[UITabBarItem alloc] initWithIcon:FontAwesomeIconBookIcon size:CGSizeMake(20.0, 20.0) title:@"Catalog"];

// UIBarButtonItem
[[UIBarButtonItem alloc] initWithIcon:FontAwesomeIconCogIcon size:CGSizeMake(24.0, 24.0) target:self action:@selector(didTapButton)];

// UIButton
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
[button setIconImageWithIcon:FontAwesomeIconHeartIcon size:CGSizeMake(44.0, 44.0) color:nil forState:UIControlStateNormal];

Sample Project

Check out the sample project, everything is demo'd there. Sample Project

Give Iconic a test drive by simply doing pod try Iconic in your terminal, and pick the Samples.xcworkspace.

On the sample project, Iconic is installed as a development pod. Because of this, pod files are not versioned. Therefore, if you clone the repo manually, you will to install the pods yourself.

About watchOS support:

When running the watchOS example, you might get a "No such module CoreText" error. This is because the CoreText.framework is missing for the watchOS Simulator. Run the 'WatchSimulator-CoreText-Patch.sh' script located in this repository, to copy the CoreText header files from the WatchOS SDK. You will then be able to run the watchOS sample with no issues as well as running Iconic on your Watch apps in the simulator.

Icon Font Catalog

Besides the auto-generated Swift code, an icon font catalog will be added in Pods/Iconic/Source/Catalog. Use this as a visual reference about the icons and their names.

Icon Font Catalog

Note: if you are using Chrome as your default browser, you will need to restart it using the open -a 'Google Chrome' --args -allow-file-access-from-files in the command line to be able to open view the catalog. This is because the html's javascript loads a local json file and Chrome has built-in security features to disable it. You can also use any other web browser like Safari or Firefox to open the catalog html.

Icon Font Samples

This repository also includes a few open source and free icon fonts for you to try Iconic with:

Acknowledgements

Iconic was originally developed by Ignacio Romero Zurbuchen. For more credits, please see AUTHORS.md.

License

This library is licensed under the Apache 2.0 license.

SwiftGen is licensed under the MIT License.

The Font Awesome font is licensed under the SIL OFL 1.1 License

More Repositories

1

core

🏑 Open source home automation that puts local control and privacy first.
Python
72,637
star
2

operating-system

πŸ”° Home Assistant Operating System
Python
4,890
star
3

home-assistant.io

πŸ“˜ Home Assistant User documentation
HTML
4,873
star
4

frontend

🍭 Frontend for Home Assistant
TypeScript
4,014
star
5

android

πŸ“± Home Assistant Companion for Android
Kotlin
2,296
star
6

supervisor

🏑 Home Assistant Supervisor
Python
1,745
star
7

supervised-installer

Installer for a generic Linux system
Shell
1,712
star
8

iOS

πŸ“± Home Assistant for Apple platforms
Swift
1,567
star
9

addons

βž• Docker add-ons for Home Assistant
Shell
1,540
star
10

homebridge-homeassistant

DEPRECATED in favor of native HomeKit support. - ο£Ώ Homebridge plugin for Home Assistant
JavaScript
684
star
11

intents

Intents to be used with Home Assistant
Python
449
star
12

architecture

Repo to discuss Home Assistant architecture
317
star
13

developers.home-assistant

Developers website for Home Assistant.
JavaScript
302
star
14

home-assistant-js-websocket

🚑 JavaScript websocket client for Home Assistant
TypeScript
272
star
15

os-agent

Daemon allowing to control OS features through D-Bus
Go
271
star
16

brands

🎨 Brands for Home Assistant
Shell
252
star
17

hassio-build

🚜 Hass.io build tools
Python
223
star
18

example-custom-config

A collection of example custom components for Home Assistant
Python
206
star
19

hadashboard

🐠 Dashing dashboard for Home Assistant (deprecated)
JavaScript
199
star
20

docker

Home Assistant containers
Dockerfile
198
star
21

cli

πŸ”³ Home Assistant command line interface
Go
195
star
22

addons-example

Example Home Assistant add-on repository
Dockerfile
123
star
23

hassbian-scripts

Scripts used in the Hassbian image.
Shell
123
star
24

ada

Hey Ada!
Python
103
star
25

fabric-home-assistant

πŸ“œ Deploy Home-Assistant easily with Fabric
Shell
100
star
26

companion.home-assistant

πŸ“– Home Assistant Companion docs
JavaScript
89
star
27

addons-development

Add-on Repository for Development
Shell
86
star
28

hassil

Intent parsing for Home Assistant
Python
86
star
29

docker-base

Home Assistant base images
Dockerfile
71
star
30

builder

Home Assistant builder script
Shell
69
star
31

data.home-assistant

Data Science Portal for Home Assistant.
JavaScript
65
star
32

home-assistant-notebooks

πŸ““ Sample Jupyter Notebooks to explore Home Assistant data
Jupyter Notebook
63
star
33

scenegen

πŸŽ† Generate Scenes for Home Assistant
Python
62
star
34

home-assistant-js

🐝 JavaScript implementation of the Home Assistant API using NuclearJS
JavaScript
58
star
35

micropython-home-assistant

🐍 Home Assistant client for MicroPython
Python
56
star
36

version

Home Assistant versions data
Shell
56
star
37

assets

🎨 Assets for the Home Assistant project
HTML
48
star
38

ui-schema

A schema to define a user interface for Home Assistant.
41
star
39

alerts.home-assistant.io

Home Assistant Alerts
HTML
40
star
40

HAKit

Swift library for communicating with Home Assistant.
Swift
38
star
41

custom-panel-starter-kit-react

A starter kit to start developing a React based custom panel
JavaScript
35
star
42

my.home-assistant.io

The portal to your home.
TypeScript
34
star
43

buildroot

Buildroot fork with patches for Home Assistant OS
Makefile
32
star
44

services.home-assistant.io

Home Assistant web services
TypeScript
31
star
45

wheels-custom-integrations

Custom integration wheels hosted by Home Assistant
30
star
46

mobile-apps-fcm-push

Push Notification Sender for Home Assistant official mobile apps
JavaScript
29
star
47

wheels

Build wheels for Home Assistant
Python
29
star
48

actions

GitHub Actions for Home Assistant workflows
Python
28
star
49

devcontainer

Custom devcontainers for the home-assistant org
Shell
28
star
50

hubot-home-assistant

πŸ’¬ Hubot module for interacting with Home Assistant via chat
CoffeeScript
28
star
51

plugin-audio

Pulseaudio implementation for Home Assistant
Shell
26
star
52

analytics.home-assistant.io

Home of the Home Assistant usage stats.
TypeScript
25
star
53

bthome.io

BTHome is a BLE API to broadcast data for your home.
HTML
25
star
54

yellow.home-assistant.io

HTML
24
star
55

plugin-observer

Supervisor plugin observare to monitor host part of Supervisor
Go
23
star
56

plugin-multicast

Multicast implementation for Home Assistant
Dockerfile
22
star
57

connectzbt1.home-assistant.io

HTML
22
star
58

plugin-dns

CoreDNS implementation for Home Assistant
Go
20
star
59

tempio

A template helper for config files
Go
19
star
60

hass-release

Home Assistant release helper scripts
Python
17
star
61

service-hub

Monorepo for NestJS services
TypeScript
15
star
62

probot-home-assistant

Probot to deal with PR/Issue automations for Home Assistant
TypeScript
13
star
63

.github

Default Community Health Files for GitHub Repos
13
star
64

landingpage

JavaScript
11
star
65

plugin-cli

CLI implementation for Home Assistant
Dockerfile
11
star
66

hassbot

HassBot is the chat assistant for the Home Assistant chatrooms on Gitter.
CoffeeScript
10
star
67

wheels-tensorflow

Build wheels for TensorFlow and Home Assistant
Dockerfile
10
star
68

wheels-opencv

Build opencv packages for Home Assistant
10
star
69

bot

Help with maintenance tasks.
TypeScript
9
star
70

lambda-home-assistant-github

:octocat: GitHub hook for the Home Assistant repository
Python
9
star
71

intents-package

Python package of the Home Assistant intents
Python
8
star
72

partner.home-assistant

HTML
8
star
73

deployments

HCL
8
star
74

private-demo

Repository for the private-demo image
Shell
8
star
75

devices

Collection of devices
Python
8
star
76

github-issue-maker

Create GitHub issues based on a template.
Python
7
star
77

hbmqtt-auth-home-assistant

HBMQTT Auth plugin to authenticate against Home Assistant auth
Python
7
star
78

LabelBot

A Lambda function that labels Home Assistant pull requests
JavaScript
7
star
79

green.home-assistant.io

HTML
7
star
80

ci-azure

Helper / Templates for Azure Pipelines
Roff
5
star
81

my-upnp

Go
5
star
82

people

An audit trail for who's meant to be in the Home Assistant GitHub organization - and a place to open issues for security-problem users
5
star
83

codeowners-mention

A Probot app to mention user(s) listed in CODEOWNERS on newly opened issues and PRs that have associated integration labels
JavaScript
4
star
84

operating-system-blobs

Shell
4
star
85

organization

πŸ’Ό A repository for discussing the organizational matters of Home Assistant
4
star
86

wheels-scipy

wheels-scipy
4
star
87

voice.home-assistant

[Deprecated] Website for all Home Assistant Voice
JavaScript
4
star
88

cosign

Sigstore cosign repository for Home Assistant
4
star
89

login.home-assistant.io

The login to your home.
HTML
3
star