UItextView 检测关闭突出显示链接、电话号码等
我有一个 UITextView,其中包含电话号码、电子邮件地址和网址。我可以让检测工作,这很好,但是我不希望它将文本项的颜色更改为带有下划线的蓝色,我只是希望它看起来正常,但是当您单击它时,它会执行它应该执行的操作。因此基本上是带有检测的白色文本,但不会改变检测到的项目的外观。
I have a UITextView which contains a phone number, email address and web url. I can get the detection to work which is fine however I dont want it to change the colour of the text items to blue with underline I just want it to look normal but when you click it it does what its supposed to do. So basically white text with detection but without changing the appearance of the detected item.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过
textView.dataDetectorTypes = UIDataDetectorTypeNone;
?有关更多数据检测器类型,请参阅此 UIKit 数据类型参考。
Did you try
textView.dataDetectorTypes = UIDataDetectorTypeNone;
?For more data detector types see this UIKit Data Types Reference.
我不知道有什么方法可以使用常规的 UITextView 来实现这一点。
但是,您可以将
UIWebView
与dataDetectors = UIDataDetectorTypeAll;
(或您需要的任何配置)结合使用。您还需要生成 HTML(最好在您的应用程序中)并使用 CSS 样式来呈现您想要的链接。例如:可能看起来有点古怪......但值得一试! (我还没有在实践中对此进行过测试,请告诉我它是否有效......谢谢)。
I don't know of any way of achieving that using a regular UITextView.
However, you could use a
UIWebView
withdataDetectors = UIDataDetectorTypeAll;
(or whichever configuration you need). You would also need to generate the HTML (preferably in your app) and use CSS styles to render links however you want. For example:Might seem a little quirky... but it's worth a shot! (I haven't tested this in practice, please let me know if it works.. Thanks).