Edit
See my answer for a full working solution:
I managed to solve this myself by using a UITextView
instead of a UILabel
If you don't mind rewriting you code, you should use UITextView
instead of UILabel
.
You can easily detect the link by setting UITextView
's dataDetectorTypes
and implement the delegate function to retrieve your clicked urls.
func textView(_ textView: UITextView, shouldInteractWith URL: URL,
in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool
https://developer.apple.com/documentation/uikit/uitextviewdelegate/1649337-textview