eddiekaiger / SwiftyAttributes

A Swifty API for attributed strings
MIT License
1.63k stars 84 forks source link

withLink Fails #10

Closed drieran closed 7 years ago

drieran commented 7 years ago

See this test

        let r1 = "Hi ".withTextColor(.black).withFont(UIFont(name: "Futura-Medium", size: 10.0)!)
        let r2 = "Google".withTextColor(.black).withUnderlineStyle(.styleSingle).withFont(UIFont(name: "Futura-Medium", size: 10.0)!).withLink(URL(string: "https://www.google.com")!)
        let r3 = " and ".withTextColor(.black).withFont(UIFont(name: "Futura-Medium", size: 10.0)!)
        let r4 = "Yahoo".withTextColor(.black).withUnderlineStyle(.styleSingle).withFont(UIFont(name: "Futura-Medium", size: 10.0)!).withLink(URL(string: "https://www.yahoo.com")!)

        blaBlaBla.attributedText = r1 + r2 + r3 + r4
        blaBlaBla.isUserInteractionEnabled = true

Links are not clickable.

eddiekaiger commented 7 years ago

What is blaBlaBlah. Is that a UILabel, UITextView... ?

drieran commented 7 years ago

Sorry, I missed. This control is an UILabel

eddiekaiger commented 7 years ago

UILabels are not automatically clickable with links. See this answer on SO: http://stackoverflow.com/a/28519273/2719866.

eddiekaiger commented 7 years ago

And also this one: http://stackoverflow.com/a/21630187/2719866