indragiek / INDLinkLabel

A simple, no frills UILabel subclass with support for links

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

Example app

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

License

INDLinkLabel is licensed under the MIT License. See LICENSE for more information.

About

A simple, no frills UILabel subclass with support for links

License:MIT License


Languages

Language:Swift 100.0%