文字添加图片
2019-06-18 本文已影响0人
Skysama
NSMutableAttributedString * attriStr = [[NSMutableAttributedString alloc] initWithString:@"你好呀"];
/**
添加图片到指定的位置
*/
NSTextAttachment *attchImage = [[NSTextAttachment alloc] init];
// 表情图片
attchImage.image = [UIImage imageNamed:@"icon"];
// 设置图片大小
attchImage.bounds = CGRectMake(2, 0, 12, 12);
NSAttributedString *stringImage = [NSAttributedString attributedStringWithAttachment:attchImage];
[attriStr insertAttributedString:stringImage atIndex:4];
cell.textLabel.attributedText = attriStr;