title: How to embed UIImage to UILabel in Swift?
body: <p>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.</p>
  
  <p>I found this is one way to embed the image into the ui label:</p>
  
  <pre><code>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`
  </code></pre>
  
  <p>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 <strong>both the text and the uiimage.</strong></p>