WSTagsField
  • October 17, 2023

An iOS text field that represents tags, hashtags, tokens in general.

Usage


 

let tagsField = WSTagsField()
tagsField.layoutMargins = UIEdgeInsets(top: 2, left: 6, bottom: 2, right: 6)
tagsField.contentInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
tagsField.spaceBetweenLines = 5.0
tagsField.spaceBetweenTags = 10.0
tagsField.font = .systemFont(ofSize: 12.0)
tagsField.backgroundColor = .white
tagsField.tintColor = .green
tagsField.textColor = .black
tagsField.fieldTextColor = .blue
tagsField.selectedColor = .black
tagsField.selectedTextColor = .red
tagsField.delimiter = “,”
tagsField.isDelimiterVisible = true
tagsField.placeholderColor = .green
tagsField.placeholderAlwaysVisible = true
tagsField.keyboardAppearance = .dark
tagsField.returnKeyType = .next
tagsField.acceptTagOption = .space
tagsField.shouldTokenizeAfterResigningFirstResponder = true

// Events
tagsField.onDidAddTag = { field, tag in
print(“DidAddTag”, tag.text)
}

tagsField.onDidRemoveTag = { field, tag in
print(“DidRemoveTag”, tag.text)
}

tagsField.onDidChangeText = { _, text in
print(“DidChangeText”)
}

tagsField.onDidChangeHeightTo = { _, height in
print(“HeightTo”, height)
}

tagsField.onValidateTag = { tag, tags in
// custom validations, called before tag is added to tags list
return tag.text != “#” && !tags.contains(where: { $0.text.uppercased() == tag.text.uppercased() })
}

print(“List of Tags Strings:”, tagsField.tags.map({$0.text}))

Installation


 Carthage

To install it, simply add the following line to your Cartfile:

github “whitesmith/WSTagsField”

Then run carthage update.

Follow the current instructions in Carthage’s README for up to date installation instructions.

 CocoaPods

To install it, simply add the following line to your Podfile:

pod “WSTagsField”

Then run pod install with CocoaPods 1.8.0 or newer.

Swift Package Manager

Using Xcode 11, just go to “File” > “Swift Packages” > “Add Package Dependency…” and use this repository: https://github.com/whitesmith/WSTagsField.

Manually

Download all the source files and drop them into your project.

Requirements


  • iOS 9.0+
  • Xcode 11 (Swift 5.1)

GitHub


View Github

#animation #awesemetextfield #carthage #carthageinstallation #cocoapods #currencytextfield #customtextfield #customwidgets #facetedsearch #geosearch #growingtextview #hashtag #hashtags #instantsearch #interfacebuilder #ios #ioslibrary #iosswift #opensource #passwordtextfield #placeholder #placeholdertextview #realmswift #search #searchengine #searchinterface #searchsynonyms #styledtext #swift #swiftframework #swiftlibrary #swiftpackagemanager #swiftui #swiftuicomponents #tags #text #textexpansion #textfield #texture #textview #tjtextfield #ui #uicomponents #uikit #uitextfield #uitextfieldnavigation #uitextview #uitextviewalgolia #widgets
YOU MIGHT ALSO LIKE...
exyte

     

camerakit-ios

CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service ...

HybridCamera

[video width="192" height="416" mp4="https://swiftgit.com/wp-content/uploads/2024/12/68747470733a2f2f7261776769742e636f6d2f7374796c656b69742f696d672f6d61737465722f7669645f6564697465645f325f326d622e676966.mp4"][/video]

TakeASelfie

An iOS framework that uses the front camera, detects your face and takes a selfie. This api opens the front ...

iOS-Depth-Sampler

Code examples of Depth APIs in iOS