SwiftRichString icon indicating copy to clipboard operation
SwiftRichString copied to clipboard

Link rendered by default with underline and blue style

Open nebillo opened this issue 5 years ago • 2 comments

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

nebillo avatar Feb 06 '20 15:02 nebillo

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?

malcommac avatar Feb 08 '20 15:02 malcommac

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 :)

stefanomondino avatar Nov 01 '21 21:11 stefanomondino