Latest 1.0
Homepage https://github.com/devcarlos/ActionLabel
License MIT
Platforms ios 8.0, requires ARC
Authors

ActionLabel Badge w/ Version Platform Carthage compatible Build Status license MIT

Custom UILabel replacement to recognize, colorize and allow custom action handlers for Hashtags (#), Mentions (@) and URLs (http/https).

Features

  • Swift 2+
  • Support #Hashtags, @Mentions and http://links
  • Replacement for UILabel to use in Posts
  • Easy installation and customization

Usage

import ActionLabel

let label = ActionLabel()

//Custom Label Setup
label.text = "Post text #with #multiple #hashtags and some users like @carlosalcala or @twitter. Links are also supported like  http://www.apple.com or http://www.twitter.com/carlosalcala"
label.textColor = .blackColor()
label.hashtagColor = .blueColor()
label.linkColor = .blueColor()
label.mentionColor = .blueColor()

//hashtag custom handler
label.hashtagHandler { hashtag in
  print("Tapped the (hashtag) hashtag")
}

//set frame
label.frame = CGRect(x: 10, y: 100, width: view.frame.width - 20, height: 500)

//add to current view
view.addSubview(label)

Install (iOS 8+)

Carthage

Add the following to your Cartfile and follow these instructions

github "devcarlos/ActionLabel"

CocoaPods

To integrate ActionLabel into your project add the following to your Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'ActionLabel'

Alternatives

ActionLabel is based mostly on ActiveLabel project but most of the recognition and regular expression logic has been rewritten, moved and improved to be a more DRY Pattern, module and single class to make this is a more simple control ready for customization.

  • ActiveLabel (Swift) – UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift
  • TTTAttributedLabel (ObjC) – A drop-in replacement for UILabel that supports attributes, data detectors, links, and more
  • STTweetLabel (ObjC) – A UILabel with #hashtag @handle and links tappable
  • AMAttributedHighlightLabel (ObjC) – A UILabel subclass with mention/hashtag/link highlighting
  • KILabel (ObjC) – A simple to use drop in replacement for UILabel for iOS 7 and above that highlights links such as URLs, twitter style usernames and hashtags and makes them touchable

License

ActionLabel is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ActionLabel",
    "version": "1.0",
    "summary": "Custom drop-in UILabel replacement that recognize and handle Hashtags (#), Mentions (@) and URLs (http://) written in Swift.",
    "homepage": "https://github.com/devcarlos/ActionLabel",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Carlos Alcala": "[email protected]"
    },
    "social_media_url": "http://twitter.com/carlosalcala",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/devcarlos/ActionLabel.git",
        "tag": "1.0"
    },
    "source_files": "ActionLabel/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This