gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 05:43:39 25 4
gpt4 key购买 nike

enter image description here

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

我不想使用私有(private) API 建议,所以我使用了 textView:shouldInteractWithURL:inRange:。然而,到目前为止我得到了... enter image description here

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
}

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

最佳答案

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

尝试插入:

textView.tintColor = UIColor.clear

和/或

textView.backgroundColor = UIColor.clear

..进入你的方法。

希望对您有所帮助。

关于ios - 是否可以在 UITextview 链接选择上设置清除颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50026837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com