title: iOS - Swift how to make links clicked in UILabel
body: <p>This is my code that show the Links in a UILabel</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var textFiled: UITextField!
  
      @IBOutlet weak var label: UILabel!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          let attrStr = try! NSAttributedString(
              data: "This is a link &lt;a href='http://www.google.com'&gt;google&lt;/a&gt;".dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!,
              options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
              documentAttributes: nil)
          label.attributedText = attrStr
      }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/reRSr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/reRSr.png" alt="enter image description here"></a></p>
  
  <p>As you can see from the picture, it shows the link correctly that I just want it, but the link can't click to jump to a web view or others. Actually, I need to custom the link click event, and I really have no idea:</p>
  
  <ol>
  <li>How to get the URL of the link.</li>
  <li>If there are more than one links, what I need to do.</li>
  </ol>
  
  <p>Thanks for checking this question firstly.</p>