Replace Emoticons

余生颓废 提交于 2019-12-13 04:38:29

问题


Is it possible to replace a word with emoticons?

For example

NSString *myString = @"I am sad of him"

now i want to check the word whether it contains the word "sad", if it has i want to replace that word with sad emoticons.

I am not sure how to have emoticons in the nsstring

Please let me know


回答1:


yeah, you can do this using this:

myString = [NSString stringByReplacingOccurrencesOfString:@"sad" withString:@"\ue058"];

Check this link for emoji codes: (replace the &#x with \u though) http://barrow.io/posts/iphone-emoji/




回答2:


you can use NSAttributed String to show emotion icon but before that you have to search "sad" word in whole paragraph by using normal search method. :)



来源:https://stackoverflow.com/questions/9820963/replace-emoticons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!