是否可以在UITextview链接选择上设置清除颜色?

时间:2018-04-25 16:10:25

标签: ios swift hyperlink uitextview

enter image description here

我想在点击链接时清除灰色选择框但我仍然找不到解决方案。因此,我正在尝试根据How to change UITextView Hyperlink selection background color?

更改选择颜色

我不想使用私有API建议,因此我使用了func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool { textView.textStorage.beginEditing() textView.textStorage.addAttribute(.backgroundColor, value: UIColor.white, range: characterRange) textView.textStorage.addAttribute(.foregroundColor, value: UIColor.white, range: characterRange) textView.textStorage.endEditing() return true } 。但是,到目前为止我得到了...... enter image description here

where

我不知道如何消除灰框。我还查看了NSAttributedStringKey中的属性,但仍然没有线索。

1 个答案:

答案 0 :(得分:-1)

您有两个选择,或者您可能需要同时实施这两个选项,具体取决于您要查找的内容。

尝试插入:

textView.tintColor = UIColor.clear

和/或

textView.backgroundColor = UIColor.clear

..进入你的方法。

希望有所帮助。

相关问题