DWIMFaceView_IOS 是IM对话中有表情输入和对话框表情显示

jopen 9年前

DWIMFaceView

IOSIMFaceView 是IM对话中有表情输入和对话框表情显示。

Preview

image

Instructions

Face文件在expression中

//转移字符开头符号,可以是/s或者/.等。。      #define FACE_NAME_HEAD  @"["      // 表情转义字符的长度( /s占2个长度,xxx占3个长度,共5个长度 )      #define FACE_NAME_LEN   5

Usage

文本插入表情主要代码:

EmojiTextAttachment *attachment = [[EmojiTextAttachment alloc]init];      attachment.emojiSize = 20;      UIImage *image = [UIImage imageNamed:[emojiTagname objectAtIndex:i]];      attachment.image = image;      NSAttributedString *text = [NSAttributedString attributedStringWithAttachment:attachment];      [str replaceCharactersInRange:range withAttributedString:text];

输入框插入表情主要代码:

EmojiTextAttachment *emojiTextAttachment = [EmojiTextAttachment new];        //Set tag and image      emojiTextAttachment.emojiTag = emojiTags[tag];      emojiTextAttachment.image = [UIImage imageNamed:emojiTagname[tag]];        //Set emoji size      emojiTextAttachment.emojiSize = 20;        //Insert emoji image      [_contentText.textStorage insertAttributedString:[NSAttributedString attributedStringWithAttachment:emojiTextAttachment]                                            atIndex:_contentText.selectedRange.location];        //Move selection location      _contentText.selectedRange = NSMakeRange(_contentText.selectedRange.location + 1, _contentText.selectedRange.length);        [self textViewDidChange:_contentText];

项目地址: https://github.com/DavidWangTM/DWIMFaceView