All Projects → futuredapp → Gutenberg

futuredapp / Gutenberg

Licence: MIT license
Tiny library for generating attributed string with emoticons as images

Programming Languages

shell
77523 projects
swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].