【问题标题】:Html to attributed string, change link colorHtml 到属性字符串,更改链接颜色
【发布时间】:2018-08-06 15:36:53
【问题描述】:

我正在将 html 转换为属性字符串并将其加载到 UIlable ,我将超链接颜色变为蓝色,我想更改该颜色,请帮助

【问题讨论】:

  • 您需要在NSAttributedStringKey.link (Swift 4) 上调用enumerateAttribute(_:in:options:using:) 并将该范围内的属性修改为您想要的颜色。
  • 请看stackoverflow.com/q/39926951/2227743 这是关于 NSColor 但想法是一样的。

标签: swift3 swift4 nsattributedstring


【解决方案1】:

你可以通过linkTextAttributes改变链接的颜色

textView.linkTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red]

【讨论】:

    猜你喜欢
    • 2020-09-22
    • 1970-01-01
    • 2017-06-18
    • 1970-01-01
    • 1970-01-01
    • 2012-04-13
    • 2013-03-30
    • 2019-08-13
    相关资源
    最近更新 更多