You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When there are multiple clickable texts in the string, the color cannot be set differently #419
lethtmlStr="You can parse HTML with <strong>strong</strong>, <em>em</em>, and even <strong><em>nested strong and em</em></strong> tags."letemStr=StringStyle(.link(URL("emStr://")),.color(UIColor.red),.underline(.single,nil))letstrongStr=StringStyle(.link(URL("strongStr://")),.color(UIColor.green),.underline(.single,nil))letstyle=StringStyle(.font(.systemFont(ofSize:30)),.color(.black),.xmlRules([.style("em",emStr),.style("strong",strongStr),]))letattributedText=htmlStr.styled(with:style)textView.linkTextAttributes=[NSAttributedString.Key.foregroundColor:UIColor.yellow]textView.attributedText=attributedText
Two links are set. If you do not set this sentence,
Hi @zuqiu123, and thanks for your report. Unfortunately, I think this is a limitation of UITextView/UILabel, where it won't let you override the color of individual links. I don't know if TTTAttributedLabel supports multicolored links within the same attributed string, but it's worth a look.
Activity
ZevEisenberg commentedon Jun 12, 2022
Hi @zuqiu123, and thanks for your report. Unfortunately, I think this is a limitation of
UITextView/UILabel, where it won't let you override the color of individual links. I don't know if TTTAttributedLabel supports multicolored links within the same attributed string, but it's worth a look.ZevEisenberg commentedon Jun 12, 2022
You might try this as well, although I haven't tested it either https://github.com/zacwest/ZSWTappableLabel