title: How to color HTML links using NSAttributedString in iOS
body: <p>Im using a UITextView to display HTML content which works fine except links. I can set font and color for normal text like this:</p>
  
  <pre><code>let str = "&lt;font size='4' style='color:red'&gt;text is red&lt;/font&gt;"
  </code></pre>
  
  <p>which works just fine. But when trying to color the link like this nothing happens. </p>
  
  <pre><code>let str = "some text &lt;a href='http://stackoverflow.com' style='color:red'&gt; 
                link is not red!?&lt;/a&gt; some text &lt;a href='http://google.com' 
                style='color:green'&gt; link is not green!?&lt;/a&gt;"
  </code></pre>
  
  <p>This is how I set the string to the UITextView.</p>
  
  <pre><code>var attrStr = NSAttributedString(
          data: str.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!,
          options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
          documentAttributes: nil,
          error: nil)
  myTextView.attributedText = attrStr
  </code></pre>
  
  <p>EDIT: </p>
  
  <p>Can edit all link colors with this code. Not possible to have different colors depending on the link though, which was what I was looking for. </p>
  
  <pre><code>myTextView.linkTextAttributes = [NSForegroundColorAttributeName: UIColor.greenColor()]
  </code></pre>