Add tappable hashtags and @mentions to a social media feed cell without building custom text parsing from scratch.
Display user-generated content in an iOS app that automatically highlights and makes URLs and email addresses clickable.
Define a custom tap pattern with a regular expression to detect and respond to any text format your app needs.
Replace UILabel with ActiveLabel in a Twitter- or Instagram-style app to get interactive text with minimal code.
Requires iOS 10+ and Swift 5, add via CocoaPods or Carthage and swap UILabel for ActiveLabel in your code or storyboard.
ActiveLabel is a Swift library for iOS that upgrades the standard text label component used in iPhone and iPad apps. The built-in UILabel in Apple's development framework displays plain or styled text, but it cannot detect and respond to taps on hashtags, usernames, or links within that text. ActiveLabel replaces it with a version that can. Out of the box, ActiveLabel highlights and makes tappable four types of content: hashtags (words starting with #), mentions (words starting with @), URLs, and email addresses. When a user taps on any of these, your app receives a callback with the tapped value so you can decide what to do, such as opening a profile page or launching a browser. You can also define custom patterns using regular expressions if you need to detect something beyond the four built-in types. The colors used for each type of highlighted text are configurable individually. Long URLs can be trimmed to a maximum display length so they do not overflow the label. The library includes a batch customization method that lets you set multiple properties at once without triggering a visual refresh for each individual change. Installation follows the standard iOS library process, supporting CocoaPods and Carthage, both of which are tools that manage third-party code in Apple platform projects. The library requires iOS 10 or newer and is written in Swift 5. This was built after the developers at Optonaut tried several existing alternatives and found them unsatisfactory in quality or ease of use. The README lists those alternatives at the bottom for reference.
← optonaut on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.