// // M80AttributedLabel+NIMKit // NIM // // Created by chris. // Copyright (c) 2015 Netease. All rights reserved. // #import "M80AttributedLabel+NIMKit.h" #import "YOUPAINIMInputEmoticonParser.h" #import "YOUPAINIMInputEmoticonManager.h" #import "UIImage+NIMKit.h" @implementation M80AttributedLabel (NIMKit) - (void)nim_setText:(NSString *)text { [self setText:@""]; NSArray *tokens = [[YOUPAINIMInputEmoticonParser currentParser] tokens:text]; for (NIMInputTextToken *token in tokens) { if (token.type == NIMInputTokenTypeEmoticon) { NIMInputEmoticon *emoticon = [[YOUPAINIMInputEmoticonManager sharedManager] emoticonByTag:token.text]; UIImage *image = [UIImage nim_emoticonInKit:emoticon.filename]; if (image) { [self appendImage:image maxSize:CGSizeMake(18, 18)]; } } else { NSString *text = token.text; [self appendText:text]; } } } @end