使用RDSActionLabel 1.0.0

RDSActionLabel 1.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2016年12月
SwiftSwift版本3.0
SPM支持SPM

Radoslav Stankov 维护。



  • Radoslav Stankov

RDSActionLabel

一个UILabel子类,为标签提供突出显示支持。支持标签、提及其它,并具有识别自定义文本的能力。使用Swift编写。

安装

use_frameworks!

pod 'RDSActionLabel'

用法

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) }

演示

自定义匹配器的定义

let label = RDSActionLabel()

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

在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];
}];

测试

gem install scan
./bin/test

贡献

  1. 分叉它
  2. 创建您的功能分支(git checkout -b my-new-feature
  3. 提交您的更改(git commit -am '添加一些功能'
  4. 将分支推送到远程仓库(git push origin my-new-feature
  5. 运行测试
  6. 创建新的拉取请求

许可证

MIT许可证