EmojiConvertToString.m 938 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // EmojiConvertToString.m
  3. // BuguLive
  4. //
  5. // Created by 朱庆彬 on 2017/8/15.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "EmojiConvertToString.h"
  9. #import "ChatEmojiIcons.h"
  10. @implementation EmojiConvertToString
  11. + (NSString *)convertToCommonEmoticons:(NSString *)text
  12. {
  13. //表情数量
  14. NSInteger emojiCount = [ChatEmojiIcons getEmojiPopCount];
  15. NSMutableString *retText = [[NSMutableString alloc] initWithString:text];
  16. for (NSInteger i = 1; i <= emojiCount; i++)
  17. {
  18. NSRange range;
  19. range.location = 0;
  20. range.length = retText.length;
  21. [retText replaceOccurrencesOfString:[NSString stringWithFormat:@",face.bundle/%@.png", @(i)]
  22. withString:[NSString stringWithFormat:@"[em_%@]", @(i)]
  23. options:NSLiteralSearch
  24. range:range];
  25. }
  26. return retText;
  27. }
  28. @end