DPTagDetectionTextView
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
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, tag: DPTag) {
}
func insertTag(at index: Int, tag: DPTag) {
}
func detectTag(at index: Int, tag: DPTag) {
}
}