UILabel 添加图片

时间:2023-03-09 13:24:58
UILabel 添加图片
//设置显示图片
NSMutableAttributedString * cellAttributeStr = [[NSMutableAttributedString alloc]initWithString:[self.textArr objectAtIndex:indexPath.row]];
NSTextAttachment * attachMent = [[NSTextAttachment alloc]initWithData:nil ofType:nil];
UIImage * image = [UIImage imageNamed:[self.imageArr objectAtIndex:indexPath.row]];
attachMent.image = image;
attachMent.bounds = CGRectMake(0, 0, 9, 9);
NSAttributedString * imageAttributeStr = [NSAttributedString attributedStringWithAttachment:attachMent];
[cellAttributeStr insertAttributedString:imageAttributeStr atIndex:0];
cell.textLbl.attributedText = cellAttributeStr;

  在后面如何设置距离text的距离,还不知道。