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的距离,还不知道。

原文地址:https://www.cnblogs.com/tanglimei/p/5323321.html