Latest 1.0.0
Homepage https://github.com/RStankov/RDSActionLabel
License MIT
Platforms ios 9.0
Authors

Build Status
Pod Version

A UILabel subclass, that adds highlighting support to labels. Supporting hashtags, mentions, urls and having the ability to recognize custom texts. Written in Swift.

Installation

use_frameworks!

pod 'RDSActionLabel'

Usage

let label = RDSActionLabel()

label.text = "Comment containing several #hash-1 #hash-2 from @username linking to http://example.com"

label.matchUsername(color: mentionColor, selectedColor: mentionSelectedColor) { self.selectUser($0) }
label.matchHashtag(color: hashtagColor, selectedColor: hashtagSelectedColor) { self.selectHash($0) }
label.matchUrl(color: URLColor, selectedColor: URLSelectedColor) { self.selectUrl($0) }

Demo

RDSActionLabel

Defining your own matchers

let label = RDSActionLabel()

label.match("custom regular expression", color: color, selectedColor: selectedColor) { self.handle($0) }

Use in Objective-C

#import "RDSActionLabel-Swift.h"

RDSActionLabel *label = [RDSActionLabel new]

// you can pass `nil` for using the default values
[self.legalLabel matchUrlWithColor:urlColor selectedColor:selectedUrlColor handle:^(NSString * _Nonnull urlString) {
  [self handleUrl:urlString];
}];

Tests

gem install scan
./bin/test

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Run the tests
  6. Create new Pull Request

License

MIT License

Latest podspec

{
    "name": "RDSActionLabel",
    "version": "1.0.0",
    "summary": "Custom text highlighting in UILabel.",
    "description": "A UILabel subclass, that adds highlighting support to labels. Supporting hashtags, mentions, urls and having the ability to recognize custom texts. Written in Swift.",
    "homepage": "https://github.com/RStankov/RDSActionLabel",
    "license": {
        "type": "MIT",
        "file": "LICENSE.txt"
    },
    "authors": {
        "Radoslav Stankov": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/RStankov/RDSActionLabel.git",
        "tag": "1.0.0"
    },
    "source_files": "RDSActionLabel/*.{swift}",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This