Skip to content

Tiny library for generating attributed string with emoticons as images

License

Notifications You must be signed in to change notification settings

futuredapp/Gutenberg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, ales@thefuntasty.com

License

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

About

Tiny library for generating attributed string with emoticons as images

Resources

License

Stars

Watchers

Forks

Packages

No packages published