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

posted @ 2016-03-26 16:52  羊羊羊🐑  Views(265)  Comments(0Edit  收藏  举报