NSTextView insert image in between text
问题 Is it possible to insert an image (not a background image) into an NSTextView ? Something like: Hi :) How are you? and it should display a "smiley" image. I have an NSTextView and an NSImage . 回答1: Insert NSImage into NSTextView: NSImage * pic = [[NSImage alloc] initWithContentsOfFile:@"/Users/Anne/Desktop/Sample.png"]; NSTextAttachmentCell *attachmentCell = [[NSTextAttachmentCell alloc] initImageCell:pic]; NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; [attachment