INDLinkLabel
INDLinkLabel copied to clipboard
A simple, no frills UILabel subclass with support for links
INDLinkLabel
A simple, no frills UILabel subclass with support for links
All I wanted was a UILabel that had support for handling taps on links. I didn't want loads of additional styling properties or built in support for parsing links and hashtags. I just wanted to be able to give it an NSAttributedString that had links already marked using NSLinkAttributeName and have it handle taps on those links like the way UITextView does. I couldn't find an existing project that met that criteria so I built this.
Run the example app to see it in action:

Handling Link Actions
INDLinkLabel provides two delegate methods that are called when a link is tapped or long pressed:
optional func linkLabel(label: INDLinkLabel, didTapLinkWithURL URL: NSURL)
optional func linkLabel(label: INDLinkLabel, didLongPressLinkWithURL URL: NSURL)
Limitations
UILabel's adjustsFontSizeToFitWidth property (and its associated properties) are not supported.
Contact
- Indragie Karunaratne
- @indragie
- http://indragie.com
License
INDLinkLabel is licensed under the MIT License. See LICENSE for more information.