Giter Site home page Giter Site logo

gutenberg's Introduction

Gutenberg

Version License Platform

Gutenberg is tiny library that can generate NSAttributedString from given string and replace registered characters with images (emoji).

Usage

Import Gutenberg

import Gutenberg

Create as many emoji as you want

let emoji1 = Emoji(code: "*angry*", image: UIImage(named: "angry")!)
let emoji2 = Emoji(code: "*grin*", image: UIImage(named: "grin")!)

Set default height and offset based on your preferred font so the emojis are aligned nicely (optional)

Gutenberg.setDefaultHeight(self.textLabel.font.lineHeight)
Gutenberg.setDefaultYOffset(self.textLabel.font.descender)

And register them

Gutenberg.registerEmoji(emoji1, emoji2)

Then create label

@IBOutlet weak var textLabel: GutenbergLabel!

and set the text

self.textLabel.text = "Hey! *grin* Where are you? *angry*"

And that's all. If you don't want to use our GuttenbergLabel (it's just UILabel subclass), there is also an extension for UILabel with method gtb_text:.

self.textLabel.gtb_text = "Hey! *grin* Where are you? *angry*"

It's just cosmetics :-)

Requirements

There are no special requirements. Gutenberg takes advantage of the NSTextAttachment class to replace the occurences of registered strings with them.

Installation

Gutenberg is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Gutenberg"

Author

Aleš Kocur, [email protected]

License

Gutenberg is available under the MIT license. See the LICENSE file for more info.

gutenberg's People

Contributors

tomaskraina avatar

Stargazers

Anıl Göktaş avatar TOYAMA Yosaku avatar mono — Masayuki Ono avatar Wayne Dahlberg avatar  avatar Eric Carlson avatar WL avatar luohaoyuan avatar Wang Ming avatar Henrique Sasaki Yuya avatar Jason Jobe avatar  avatar Carabineiro avatar Aleš Kocur avatar

Watchers

HoNooD avatar James Cloos avatar Jakub Knejzlík avatar Carabineiro avatar Aleš Kocur avatar Michal Simik avatar Vojtěch Janoušek 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.