UILabel中的可点击文本 [英] Clickable text in UILabel

查看:56
本文介绍了UILabel中的可点击文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有一个带有可点击文本的标签,我在这里阅读有关FancyLabel的答案.是否有一些新的替代方法?我知道我也可以为此使用UIWebView,但这会很慢,是否有更好的方法来实现呢?谢谢

I need to have a label with clickable text, I read answers here suggesting FancyLabel. Is there some new alternative to it? I know I could also use UIWebView for that but that would be to slow, is there some better way to achieve that? Thanks

推荐答案

您只需将 userInteractionEnabled 设置为 YES ,然后添加 UITapGestureRecognizer UILabel 上,以检测有人何时点击它.

You could just set userInteractionEnabled to YES on it, then add a UITapGestureRecognizer to the UILabel to detect when someone taps on it.

如果您只希望单击部分文本,那么您将需要做更多的工作,并且可能希望成为一个完全自定义的视图,该视图可以处理所有业务逻辑以执行复杂的操作

If you want only part of the text to be clickable, then you're going to have to do a lot more work and would probably want to be a completely custom view which handles all of the business logic for doing something that complex.

这篇关于UILabel中的可点击文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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