TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by asashin227.
LNKLabel is customed UILabel that is linkable and highlighted.
let label = LNKLabel()
label.linkPatterns = [MailPattern(), URLPattern(), PhonePattern()]
label.text = "https://github.com/asashin227/LNKLabel\n09012345678\n[email protected]\nhogehogefugafuga"
label.delegate = self
label.numberOfLines = 0
label.frame.size.width = UIScreen.main.bounds.size.width
label.sizeToFit()
label.center = self.view.center
view.addSubview(label)
extension YourClass: LNKLabelDelegate {
func didTaped(label: LNKLabel, pattern: Pattern, matchText: String, range: NSRange) {
switch pattern {
case is URLPattern:
print("taped url link: \(matchText)")
case is MailPattern:
print("taped mail address: \(matchText)")
case is PhonePattern:
print("taped phone number: \(matchText)")
default:
break
}
}
}
public class CustomPattern: Pattern {
override public var regString: String {
return "hogehoge"
}
}
and add for link
label.linkPatterns?.append(CustomPattern())
LNKLabel is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'LNKLabel'
LNKLabel is available under the MIT license. See the LICENSE file for more info.