发布emoji

- (NSString *)fullStr// 在UITextView中的需要发送的文字文字

{

    NSMutableString *fullText = [[NSMutableString alloc] init];

        [self.attributedText enumerateAttributesInRange:NSMakeRange(0, self.attributedText.length) options:0 usingBlock:^(NSDictionary<NSString *,id> * _Nonnull attrs, NSRange range, BOOL * _Nonnull stop) {

        YSWeiBoNSTextAttachment *attachment = attrs[@"NSAttachment"];// 是否为图片

        if (attachment)// 如果是表情图片

        {

            [fullText appendString:[NSString stringWithFormat:@"%@",attachment.emotion.chs]];// 获取文字对应的描述字符串

        }

        else

        {

            NSAttributedString *attributedString = [self.attributedText attributedSubstringFromRange:range];

            [fullText appendString:attributedString.string];

        }

    }];

    

    return fullText;

}

原文地址:https://www.cnblogs.com/happyEveryData/p/5524796.html