Latest 1.0.0
Homepage https://github.com/Datt1994/DPTagDetectionTextView
License Apache 2.0
Platforms ios 9.0
Authors

Tag detection from Textview.

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate DPTagDetectionTextView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
use_frameworks!
pod 'DPTagDetectionTextView'
end

Then, run the following command:

$ pod install

Add Manually

Download Project and copy-paste DPTagTextView.swift file into your project

How to use

AddClass

👆Add DPTagTextView to UITextView Custom Class.

Properties

👆Use this properties as per your requirments.

Code

Set up

self.txtMain.dpTagDelegate = self // set DPTagTextViewDelegate Delegate 
self.txtMain.tagPrefix = "@[---" // or use Interface Builder
self.txtMain.tagPostfix = "---]" // or use Interface Builder
self.txtMain.setTagDetection(true) // true :- detecte tag on tap , false :- Search Tags using @,#,etc.
self.txtMain.arrSearchWith = ["@","#","$$"] // Search start with this strings.
let arrTags = self.txtMain.getAllTag("hello @[---Datt---]") // get all tags from string.
self.txtMain.txtFont = UIFont(name: "HelveticaNeue", size: CGFloat(15))! // set textview text font family 
self.txtMain.tagFont = UIFont(name: "HelveticaNeue-Bold", size: CGFloat(17.0))! // set textview tag font family 

var arrTags = [DPTag]()
for i in 0 ..< arrTagedUser.count { // arrTagedUser = ["Datt"]
    arrTags.append(DPTag(strTagName: arrTagedUser[i], tagID: i))
}
self.txtMain.setTxtAndTag(str: "hello @[---Datt---]", tags: arrTags)
self.txtMain.setTxt("hello @[---Datt---]")

Delegate Methods

extension ViewController : DPTagTextViewDelegate {
    func tagSearchString(_ str: String) {
    }

    func removeTag(at index: Int, tagName: String) {
    }

    func insertTag(at index: Int, tagName: String) {
    }

    func detectTag(at index: Int, tagName: String) {
    }
}

Latest podspec

{
    "name": "DPTagDetectionTextView",
    "version": "1.0.0",
    "summary": "Tag detection and tag search for Textview.",
    "homepage": "https://github.com/Datt1994/DPTagDetectionTextView",
    "license": "Apache 2.0",
    "authors": {
        "Datt1994": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "swift_version": "4.2",
    "source": {
        "git": "https://github.com/Datt1994/DPTagDetectionTextView.git",
        "tag": "1.0.0",
        "commit": "73c86d5a4c0dfb9038a0b9894589c42a22fdf9b5"
    },
    "source_files": "TagNameDetection/TagNameDetection/DPTagTextView.swift"
}

Pin It on Pinterest

Share This