开发者

Clickable words in UILabel

开发者 https://www.devze.com 2023-02-09 08:05 出处:网络
Is there a 3rd party library which allows contents of UILabel (words) to receive events (for example click, double click, etc)? I\'m interested 开发者_C百科in distinguishing which word received an eve

Is there a 3rd party library which allows contents of UILabel (words) to receive events (for example click, double click, etc)? I'm interested 开发者_C百科in distinguishing which word received an event.


@Zepplock I dont know about any 3rd party library, but try this link,

UILabel touch and get the text where touched

I m not sure if the answer might help, but the user said that there is a sample code. so you can try it out.


The easiest way would be dividing your string and then displaying that parts on different UIButtons. But if you have a lot of text, then you probably need to check docs for Core Text. It will allow you to get coordinates of word/sentence/letter and then you can add some overlay (e.g. UIButton) that would receive touch events. Or you can override UIResponder methods and use gesture recognizers.

0

精彩评论

暂无评论...
验证码 换一张
取 消