To create an NSTextField with text based NSTextAttachments in Swift, you need to use NSAttributedString.
Here’s an example code snippet:
main.swift498 chars12 lines
This code creates an NSTextField, sets an NSTextAttachment with an image and creates an NSAttributedString from it. It then creates a NSMutableAttributedString and builds it by appending the NSAttributedString with the NSTextAttachment, and then appends a normal string. Finally, the NSMutableAttributedString is set as the attributedStringValue of the NSTextField.
gistlibby LogSnag