问题
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