I want to make a UILabel (for a photo tag) with a small x icon in the top right corner, so that when I hit the x, the UILabel disappears.
I found this is one way to embed the image into the ui label:
var attachment = NSTextAttachment()
attachment.image = UIImage(named: "rsz_cancel30.png")
var attachmentString = NSAttributedString(attachment: attachment)
var myString = NSMutableAttributedString(string: labelString)
myString.appendAttributedString(attachmentString)
uiLabel.attributedText = myString`
However, when I try to use uiLabel.sizetoFit(), it "sizes to fit" the image, so the label becomes the size of the small square icon, instead of fitting both the text and the uiimage.