Showing Clickable URLs and icon in UILabel

760 Views Asked by At

I am using TTTAttributedLabel for URLs and phone number in my app. Every thing is working fine but the problem is that now I need to show icon in the UILabel. Before I am using given below code. But due to use of TTTAttributedLabel now NSTextAttachment is not showing in TTTAttributedLabel. TTTAttributedLabel does not support attachment. So any idea to support URLs, phone numbers and icons in UILabel?


now i decided to show unicode image in TTTAttributedLabel. and it is working fine.

1

There are 1 best solutions below

0
On

It's better to use UITextView and set the textView's data detector types.

textView.dataDetectorTypes = UIDataDetectorTypeAddress | UIDataDetectorTypeLink |     UIDataDetectorTypePhoneNumber;

There is one delegate methods that is called when the link or url in the text view is selected

- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange NS_AVAILABLE_IOS(7_0);

This gives you the URL tapped inside your text view and you can perform your desired action.