使用NSTextAttachment
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithAttributedString:self.textView.attributedText];
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithData:nil ofType:nil] ;
textAttachment.image = [UIImage imageNamed:@"sky.png"];
NSAttributedString *textAttachmentString = [NSAttributedString attributedStringWithAttachment:textAttachment];
[string insertAttributedString:textAttachmentString atIndex:index];//index為用戶指定要插入圖片的位置
self.textView.attributedText = string;