Search code examples
uilabelswift3tttattributedlabel

TTTAttributedLabel clickable link does not work in Swift 3


I just upgraded to Swift 3. I created a TTTAttributedLabel with a clickable URL, unfortunately the delegate function does not work anymore. Anyone has similar problems?

    func attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) {
}

Solution

  •    extension YourViewController: TTTAttributedLabelDelegate {   
            func attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) {
                UIApplication.shared.openURL(url)
            }
        }