yariksmirnov
yariksmirnov

Reputation: 489

UITextView with emoticons editing

I am developing xmpp-client app. One of the features is sending smiles and user should have ability to edit its like usuall text. Emoticons editing in Viber App is best example of what i want to implement.

I already tried three ways to solve problem:

May be some one could give me advice of really working solution?

Upvotes: 6

Views: 2089

Answers (1)

Alessandro Orrù
Alessandro Orrù

Reputation: 3513

I'm not really into rects and ranges mechanism of UITextView/UITextInput, but I try to give you an (untested) advice that maybe could achieve the expected result.

Built-in iOS emojis are simple characters, so we can follow the same path by building a custom font (or extend an existing one). We have two options:

  • If you want to target iOS 6.0 (that has native support for NSAttributedString in UIKit classes), you could try to build a custom font containing all the emoticons you need, and use it inside your NSAttributedString (attributed string can mix different fonts, font sizes, styles and so on).

  • You could do something similar with iOS 5, but since you can't use NSAttributedString inside UITextView (so you are limited to just one font for the entire text) you should use a font that combines together the actual characters and the custom emoticons: so you should extend the font you want to use for typing, by adding all the emoticons to it. I don't know if this could have licenses implications, anyway.

Otherwise, you could always go much more low-level, implementing your own custom textView using CoreText, but I think it would be a hard work.

Upvotes: 2

Related Questions