Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在Swift中更改CDMarkdownKit中的超链接颜色?_Ios_Swift_Iphone_Markdown - Fatal编程技术网

Ios 如何在Swift中更改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/

我正在使用CDMarkdownKit库进行标记链接。现在我想根据我的规格更改超链接文本的颜色。但我无法更改超链接文本的颜色

你能推荐一些其他好的图书馆来降价吗

请参阅下面的代码片段

   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]