2019独角兽企业重金招聘Python工程师标准>>>
1.//加载图片
NSTextAttachment *attch = [[NSTextAttachment alloc] init];
attch.image = [UIImage imageNamed:emotion.png];
CGFloat attchWH = self.font.lineHeight;
attch.bounds = CGRectMake(0, -4, attchWH, attchWH);
//根据附件创建一个属性文字
NSAttributedString *imageStr = [NSAttributedString attributedStringWithAttachment:attch];
2.//拼接文字
[attributedText appendAttributedString:self.attributedText];
3.//NSAttributedString转化为NSString
NSString *str = attributedText.string