malcommac / SwiftRichString

👩‍🎨 Elegant Attributed String composition in Swift sauce
MIT License
3.1k stars 211 forks source link

Link rendered by default with underline and blue style #108

Open nebillo opened 4 years ago

nebillo commented 4 years ago

Consider this snippet of code:

let normal = Style {
    $0.color = Color.green
    $0.font = Font.systemFont(ofSize: 12)
}
let link = Style {
    $0.color = Color.red
    $0.font = Font.boldSystemFont(ofSize: 19)
}
let group = SwiftRichString.StyleGroup(base: normal, ["a": link])

let text = "<a href='user'>@user</a> likes this."
return text.set(style: group)

the expected outcome is a string where the word "@username" is rendered in big bold green text (with no underline) instead what I got is a text of the correct font but with blue and underline applied to it:

Screenshot 2020-02-06 at 15 43 06

You can easily replicate this by making a test on a brand new project using the latest library version (3.7.1). Before noticing this issue we were using an old version (2.x) of the library and the default behaviour has always been the correct one described.

Can you help? thanks

malcommac commented 4 years ago

As far I know the color of the links is set by the linkAttributes property of the UITextView/UILabel instance where the text is placed. Are you sure it always works in such way?

stefanomondino commented 2 years ago

hi @malcommac , just wanted to confirm that I'm experiencing same behavior as well. linkAttributes is a property of TTTAttributedLabel, not UILabel. I guess we should dig into that library and figure out how Mattt did that some years ago :)