如何在UILabel中检测并创建可点击的超链接/提及/主题标签? [英] How to detect and make hyperlinks/mentions/hashtags clickable in UILabel?

查看:588
本文介绍了如何在UILabel中检测并创建可点击的超链接/提及/主题标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在UILabel中检测并使链接/提及/标签可点击。或者,是否有任何我可以使用的开源库(我已经看过Fancy UILabel,它不处理多行tex,TTAttributedLabel不处理提及/ hashtag)?

How to detect and make link/mention/hashtag clickable in UILabel. Alternatively, is there any open source library that I can utilize (I already looked at Fancy UILabel which doesn't handle multiline tex, TTAttributedLabel which doesn't handle mention/hashtag)?

推荐答案

当前iOS中没有办法使用UILabel ...

There is no way to do so with UILabel in the current iOS...

TTTAttributedLabel可以让您设置标签样式,但是对于可点击(或者更确切地说 - tappable )链接,您应该使用UIWebView并将其样式设置为伪装它作为一个标签,或者,你可能会变得怪异并分开你的标签并在混合中使用UIButton,但这非常混乱 - 就像一个谜题,只是......它们不适合在一起。

TTTAttributedLabel will let you style up your label, however for clickable (or rather - tappable) links you should rather either use a UIWebView and style it in such a was as to disguise it as a Label, or, you could get geeky and split your labels up and use a UIButton in the mix, but that's very messy - like a puzzle, only... they don't fit together.

您可能拥有的最后一个选项是在链接上叠加UIButton,但这需要您知道链接的位置,因为问题是关于检测链接等。 。

Last option you might have is to overlay a UIButton over a link, but this requires that you know where the link is and since the question was about detecting links etc...

您应该深入了解UIWebView。

You should really look into UIWebView.

这篇关于如何在UILabel中检测并创建可点击的超链接/提及/主题标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆