title: How to put UIImage in front of UILabel - Swift
body: <p>I have a UILabel that states where the User if from (location) and i want to put a small icon in from of the text.</p>
  
  <pre><code>let attachment = NSTextAttachment()
  attachment.image = UIImage(named: "geolocationIcon")
  let attachmentString:NSAttributedString = NSAttributedString(attachment: attachment)
  let myString: NSMutableAttributedString = NSMutableAttributedString(string: location + " ")
  myString.appendAttributedString(attachmentString)
  otherUserLocationLabel.attributedText = myString
  </code></pre>
  
  <p>and it currently shows like this</p>
  
  <p><a href="http://i.stack.imgur.com/bZ8tw.jpg" rel="nofollow">http://s16.postimg.org/vsnd8v5g1/UILABEL.jpg</a></p>
  
  <p>How do i put the icon in front of the text ?
  Thanks!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I ended up creating a Custom UIButton and then simply added the UIImage and Text as follows.</p>
  
  <pre><code>            otherUserLocationButton.setImage(UIImage(named: "geolocationIcon"), forState: .Normal)
              otherUserLocationButton.setTitle(" " + location, forState: .Normal)
  </code></pre>