OK check this out google.com.my -6ren">
gpt4 book ai didi

iOS UITextView : URL Detection for links with country domain and without "http" prefix

转载 作者:行者123 更新时间:2023-11-28 12:56:03 24 4
gpt4 key购买 nike

从 iOS 9.2 开始,UITextView URL 检测的工作方式如下:

check this out google.com -> OK

check this out google.com.my -> NOT OK (its not highlighting)

check this out http://google.com -> OK

check this out http://google.com.my -> OK

我的问题是如何让 textview 自动突出显示上面的第二个示例 (google.com.my)?

谢谢!

最佳答案

据我所知,您无法创建自定义 url 检测方案。

您可以使用 NSregularExpression 解析自定义域(简单地提取字符串作为 url)然后您可以使用 NSAttributedString 以不同颜色标记链接。

关于iOS UITextView : URL Detection for links with country domain and without "http" prefix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34989861/

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