Latest 5.0.0
Homepage https://github.com/whitesmith/WSTagsField
License MIT
Platforms ios 9.0, requires ARC
Frameworks UIKit
Authors

Carthage Compatible
CocoaPods Compatible
Swift 5
Platforms iOS
[Build Status]()
License MIT

An iOS text field that represents different Tags.

WSTagsField

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.returnKeyType = .next
tagsField.acceptTagOption = .space

// 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

WSTagsField 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.

WSTagsField CocoaPods

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

pod "WSTagsField"

You will also need to make sure you’re opting into using frameworks:

use_frameworks!

Then run pod install with CocoaPods 1.6.0 or newer.

Manually

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

Requirements

  • iOS 9.0+
  • Xcode 10 (Swift 4)

Contributing

The best way to contribute is by submitting a pull request. We’ll do our best to respond to your patch as soon as possible. You can also submit a new GitHub issue if you find bugs or have questions. :octocat:

Credits

Whitesmith

This project was inspired by CLTokenInputView.

Latest podspec

{
    "name": "WSTagsField",
    "version": "5.0.0",
    "summary": "An iOS text field that represents different Tags",
    "homepage": "https://github.com/whitesmith/WSTagsField",
    "license": "MIT",
    "authors": {
        "Ricardo Pereira": "[email protected]"
    },
    "source": {
        "git": "https://github.com/whitesmith/WSTagsField.git",
        "tag": "5.0.0"
    },
    "social_media_url": "https://twitter.com/whitesmithco",
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "swift_version": "5.0",
    "source_files": [
        "WSTagsField/*.{h}",
        "Source/**/*.{h,swift}"
    ],
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This