Introducing EmojiTextView

July 21, 2016

I'm happy to announce the release of my newest open source project: EmojiTextView. iOS 10 came up with a bag of great features. One that I really liked was an easy way to replace text with emojis in Messages.app.
That's what I tried to recreate with EmojiTextView.

EmojiTextView in action

There are two main differences between EmojiTextView and Apple's implementation. They're caused by some constraints that I didn't want to break:

I wanted the library to work with any text view. This means that I couldn't rely on any of the popular tricks, such as: a separate CATextLayer for each letter, drawing text manually in a context or using snapshots of letters. So, I went with the simplest approach possible which is changing attributedText manually on each frame. That meant that I couldn't easily change font sizes without influencing the layout. (Please let me know if you have an idea for a better implementation without subclassing UITextView.)

EmojiTextView works always, not only when the emoji keyboard is selected. This is because there is no future-proof way of checking the type of a currently selected keyboard. The only thing I noticed is that when the emoji keyboard is selected UIResponder.textInputMode is nil. I reported this as a feature request (rdar://27473625).

I hope you'll enjoy playing with EmojiTextView. It's available on GitHub.