0

I am using a UILabel and setting its attributed text.

I want to add tap gesture to part of string rather than part of label. Because my UILabel is a multiline one.

I can't add gesture to part of label.

How can I add gesture to part of string. For example:

lblObject.text = @"Hi Abdul, did you see my BACKBONE book."

I want to add gesture to BACKBONE text only.

enter image description here

I want to add tap gesture to the underlined text .

Both the red box are a single text in two different lines.

Jonny C
  • 1,943
  • 3
  • 20
  • 36
Abdul Yasin
  • 3,480
  • 1
  • 28
  • 42
  • You need to use the hyperlink functionality of attributed string. That's not easy out of the box but https://github.com/TTTAttributedLabel/TTTAttributedLabel has been around a while and can do most of the heavy lifting leaving you to implement a delegate. – Warren Burton May 11 '15 at 12:33
  • you can add UILabel as subView in UILabel (main Label). Now set required text as you want & Add gesture on subView UILabel... – M Zubair Shamshad May 11 '15 at 12:34
  • @BrittoThomas. Because my UILabel is a multi line one. And the text that i want to add gesture to is on two line. I am attaching screenshot. Please review. – Abdul Yasin May 11 '15 at 12:34
  • 1
    Use UITextView then set its Detections and perform your desired actions – Raheel Sadiq May 11 '15 at 12:36

0 Answers0