CMSListCell *cell = (CMSListCell *)[self.view viewWithTag:self.tag];
// textview add image
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithAttributedString:cell.listTextView.attributedText];
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithData:nil ofType:nil] ;
textAttachment.image = editedImage; //要添加的图片
NSAttributedString *textAttachmentString = [NSAttributedString attributedStringWithAttachment:textAttachment];
[string insertAttributedString:textAttachmentString atIndex:0];//index为用户指定要插入图片的位置
cell.listTextView.attributedText = string;
iOS 在textView中添加图片
最新推荐文章于 2024-05-15 14:59:40 发布