From 83b9d5c682b21d88133f24da0f94dd56bd79e687 Mon Sep 17 00:00:00 2001 From: 单军华 Date: Thu, 19 Jul 2018 13:38:55 +0800 Subject: [PATCH] change --- screendisplay/Pods/HMEmoticon/表情键盘/Emoticon/HMEmoticonAttachment.m | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git "a/screendisplay/Pods/HMEmoticon/\350\241\250\346\203\205\351\224\256\347\233\230/Emoticon/HMEmoticonAttachment.m" "b/screendisplay/Pods/HMEmoticon/\350\241\250\346\203\205\351\224\256\347\233\230/Emoticon/HMEmoticonAttachment.m" new file mode 100755 index 0000000..084f4b5 --- /dev/null +++ "b/screendisplay/Pods/HMEmoticon/\350\241\250\346\203\205\351\224\256\347\233\230/Emoticon/HMEmoticonAttachment.m" @@ -0,0 +1,41 @@ +// +// HMEmoticonAttachment.m +// ������������ +// +// Created by ������ on 16/3/5. +// Copyright �� 2016��� itcast. All rights reserved. +// + +#import "HMEmoticonAttachment.h" +#import "HMEmoticon.h" +#import "UIImage+HMEmoticon.h" + +@implementation HMEmoticonAttachment + +- (instancetype)initWithEmoticon:(HMEmoticon *)emoticon font:(UIFont *)font { + self = [super init]; + if (self) { + _text = emoticon.chs; + + self.image = [UIImage hm_imageNamed:emoticon.imagePath]; + CGFloat lineHeight = font.lineHeight; + self.bounds = CGRectMake(0, -4, lineHeight, lineHeight); + } + return self; +} + ++ (NSAttributedString *)emoticonStringWithEmoticon:(HMEmoticon *)emoticon font:(UIFont *)font textColor:(UIColor * _Nonnull)textColor { + + HMEmoticonAttachment *attachment = [[HMEmoticonAttachment alloc] initWithEmoticon:emoticon font:font]; + + NSMutableAttributedString *emoticonStr = [[NSMutableAttributedString alloc] initWithAttributedString: + [NSAttributedString attributedStringWithAttachment:attachment]]; + + [emoticonStr addAttributes: @{NSFontAttributeName: font, + NSForegroundColorAttributeName: textColor} + range:NSMakeRange(0, 1)]; + + return emoticonStr.copy; +} + +@end -- Gitblit v1.8.0