Latest 1.0.3
Homepage https://github.com/darrendev/DZLabel
License MIT
Platforms ios 8.0
Authors

Version
License
Platform

DZLabel

Introduction

  • Base on UITextView.
  • A replacement of UILabel, but more.
  • Support for Mentions, Links, Phone Numbers, Addresses, Emoticons(images)
  • Support custom Regex links
  • Support setting link color
  • Support detections of Sinle-Tap on links, Single-Tap on Whole Text, Long-Press on links
  • Support automatic table view cell height calculation (autolayout)

Usage

1. Basic Setup

var label = DZLabel()
label.dzFont = UIFont.systemFont(ofSize: 14)
label.dzTextColor = UIColor.blue
label.dzLinkColor = UIColor.red
label.dzText = "test" // do not use .attributedText or .text

2. Enable Link Types

label.dzEnabledTypes = [
    .address,
    .phone,
    .mention,
    .url,
    .emoticon(pattern: nil, // By default: "[EmoticonName]"
              bounds: CGRect(x: 0, y: -2, width: 10, height: 10), // Position and Size
              imageNameBlock: ({ name in // Text -> Local Image Name
                var imageName = name
                if imageName.hasPrefix("[") { imageName.removeFirst() }
                if imageName.hasSuffix("]") { imageName.removeLast() }
                return imageName})),
    .regex(pattern: "AM|PM"),
]

3. Handle Callbacks

label.dzHandleMentionTap { result in
    print("mention tapped" + result)
}

label.dzHandleURLTap { result in
    print("url tapped" + result)
}

label.dzHandlePhoneTap { result in
    print("phone tapped" + result)
}

label.dzHandleAddressTap { result in
    print("address tapped" + result)
}

label.dzHandleKeywordLongPress {
    print("keyword long pressed")
}

label.dzHandleRegexKeywordTap { result in
    print("custom regex tapped" + result)
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8+
  • Swift 4

Installation

DZLabel is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'DZLabel'

Author

Darren Zheng, [email protected]

License

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

Latest podspec

{
    "name": "DZLabel",
    "version": "1.0.3",
    "summary": "iOS rich text clickable link label",
    "description": "iOS rich text clickable link label, an replacement of UILabel",
    "homepage": "https://github.com/darrendev/DZLabel",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Darren Zheng": "[email protected]"
    },
    "source": {
        "git": "https://github.com/darrendev/DZLabel.git",
        "tag": "1.0.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "DZLabel/Classes/**/*",
    "swift_version": "4.1"
}

Pin It on Pinterest

Share This