let attrStr = try! NSMutableAttributedString(
data: courseList.breadcrumb.data(using: .unicode, allowLossyConversion: true)!,
options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil)
attrStr.addAttribute(NSForegroundColorAttributeName, value: UIColor.darkGray , range: NSRange(location: 0, length: attrStr.length))
descLbl.attributedText = attrStr
descLbl.linkAttributes = [
NSForegroundColorAttributeName: UIColor.darkGray,
NSUnderlineStyleAttributeName: NSNumber(value: false),
NSUnderlineColorAttributeName : UIColor.clear
]
以上是我用于编码HTML标签的代码,并且我已经使用TTTAttributedlabel
<a href=https://www.google.com>Subject Tutorials </a> > <a href=https://www.google.com>State Boards </a> > <a href=https://www.google.com>Madhya Pradesh State Board </a> > <a href=https://www.google.com>Hindi Medium </a> > <a href=https://www.google.com>Class 6 </a>
这是我必须编码并显示为无下划线且必须更改颜色的HTML。
答案 0 :(得分:1)
将您的下划线属性的值更改为以下内容:
NSUnderlineStyleAttributeName: NSUnderlineStyle.styleNone
您的属性应如下所示:
descLbl.linkAttributes = [
NSForegroundColorAttributeName: UIColor.darkGray,
NSUnderlineStyleAttributeName: NSUnderlineStyle.styleNone,
NSUnderlineColorAttributeName : UIColor.clear
]