Ios 如何在Swift中更改CDMarkdownKit中的超链接颜色?
我正在使用CDMarkdownKit库进行标记链接。现在我想根据我的规格更改超链接文本的颜色。但我无法更改超链接文本的颜色 你能推荐一些其他好的图书馆来降价吗 请参阅下面的代码片段Ios 如何在Swift中更改CDMarkdownKit中的超链接颜色?,ios,swift,iphone,markdown,Ios,Swift,Iphone,Markdown,我正在使用CDMarkdownKit库进行标记链接。现在我想根据我的规格更改超链接文本的颜色。但我无法更改超链接文本的颜色 你能推荐一些其他好的图书馆来降价吗 请参阅下面的代码片段 self.codeLabel.delegate = self let markdown = "https://www.google.com/, This *framework* helps **with** parsing `markdown`.[Link](https://www.google.com/
self.codeLabel.delegate = self
let markdown = "https://www.google.com/, This *framework* helps **with** parsing `markdown`.[Link](https://www.google.com/)"
// Create parser
let markdownParser = CDMarkdownParser(font: UIFont(name: "HelveticaNeue", size: 16)!,
boldFont: UIFont(name: "HelveticaNeue-Bold", size: 16),
italicFont: UIFont(name: "HelveticaNeue-Thin", size: 16),
fontColor: UIColor.darkGray,
backgroundColor: UIColor.clear)
//It's not working
markdownParser.link.color = UIColor.red
markdownParser.automaticLink.color = UIColor.yellow
codeLabel.attributedText = markdownParser.parse(markdown)
codeLabel.isUserInteractionEnabled = false
如果使用UITextView渲染标记,请自行设置的属性
linkTextAttributes
。您必须这样做,因为UITextView
自己处理链接
报告说:
默认属性指定带有单个下划线和指针光标的蓝色文本
因此,您的解决方案将是:
self.codeLabel.linkTextAttributes = [.foregroundColor: UIColor.red]