Latest 0.1.8
Homepage https://github.com/iamchiwon/Tags
License MIT
Platforms ios 8.0
Dependencies Tags, RxSwift, RxCocoa
Authors

Version
License
Platform
Swift 4.0

RxExtensions

  • Based on Tags Project (version continues)

Cocoapods

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

pod 'RxTags'

Reactive extension

class ViewController: UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()

        let tagsView = TagsView()

        tagsView.touchAction()
                .subscribe(onNext: { tagButton in 
                    // Tag Touch Action
                })
                .disposed(by: disposeBag)

        tagsView.lastTagAction()
                .subscribe(onNext: { tagButton in 
                    // Last Tag Touch Action
                })
                .disposed(by: disposeBag)

        tagsView.changeHeight()
                .subscribe(onNext: { height in 
                    // TagsView Change Height
                })
                .disposed(by: disposeBag)
    }
}

Author

iamchiwon, [email protected]


Tags

Introduce

dynamically add, modify, and delete tags, and you can easily change the margins, colors, and fonts of your tags.
Tags are not broken because they are linked with Auto Layout.
Each time the height of the tag changes, you can bring the height to the delegate

demo
demo2

Requirements

Tags written in Swift 4. Compatible with iOS 8.0+

Installation

Cocoapods

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

pod 'Tags'

Usage

Xib or Storyboard file

setting

image

image

view

image
image

done!

Code editor

import Tags
let tagView = TagsView()
self.view.addSubview(tagView)

AutoLayout Example

tagView.translatesAutoresizingMaskIntoConstraints = false
self.view.addConstraint(NSLayoutConstraint(
    item: self.view,
    attribute: .leading,
    relatedBy: .equal,
    toItem: tagView,
    attribute: .leading,
    multiplier: 1,
    constant: 0)
)
self.view.addConstraint(NSLayoutConstraint(
    item: self.view,
    attribute: .trailing,
    relatedBy: .equal,
    toItem: tagView,
    attribute: .trailing,
    multiplier: 1,
    constant: 0)
)
self.view.addConstraint(NSLayoutConstraint(
    item: self.view,
    attribute: .top,
    relatedBy: .equal,
    toItem: tagView,
    attribute: .top,
    multiplier: 1,
    constant: 0)
)

done!

Property

tags

//Returned as an array of strings
tagsView.tagTextArray//get-only

//Returned as an array of TagButton
tagsView.tagArray//get-only

height

tagsView.height//get-only

padding & margin

image

tagsView.paddingLeftRight = 6
tagsView.paddingTopBottom = 4
tagsView.marginLeftRight = 6
tagsView.marginTopBottom = 4

tag

// layer radius
tagsView.tagLayerRadius = 6
// layer width
tagsView.tagLayerWidth = 1
// layer color
tagsView.tagLayerColor = .black
// text color
tagsView.tagTitleColor = .black
// background color
tagsView.tagBackgroundColor = .white
// font
tagsView.tagFont = .systemFont(ofSize: 15)
// text longer ...
tagsView.lineBreakMode = .byTruncatingMiddle
// tag add
tagsView.tags = "Hello,Swift"

lastTag

// lastTag title
tagsView.lastTag = "+"
// lastTag titleColor
tagsView.lastTagTitleColor = .black
// lastTag layer Color
tagsView.lastTagLayerColor = .black
// lastTag background Color
tagsView.lastTagBackgroundColor = .white

Method

append

tagsView.append("Hello")
tagsView.append(contentsOf: ["Hello", "World"])
tagsView.append(TagButton())
tagsView.append(contentsOf: [TagButton(), TagButton()])

update

tagsView.update("Hi", at: 0)
tagsView.update(TagButton(), at: 0)

insert

tagsView.insert("World", at: 0)
tagsView.insert(TagButton(), at: 0)

remove

tagsView.remove(0)
tagsView.remove(TagButton())
tagsView.removeAll()

lastTag

// lastTag Button
tagsView.lastTagButton(TagButton())

redraw

// ReDraw
tagsView.redraw()

Delegate

class ViewController: UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()

        let tagsView = TagsView()
        tagsView.delegate = self
    }
}

extension ViewController: TagsDelegate{

    // Tag Touch Action
    func tagsTouchAction(_ tagsView: TagsView, tagButton: TagButton) {

    }

    // Last Tag Touch Action
    func tagsLastTagAction(_ tagsView: TagsView, tagButton: TagButton) {

    }

    // TagsView Change Height
    func tagsChangeHeight(_ tagsView: TagsView, height: CGFloat) {

    }
}

Customize

TagButton Customize

let button = TagButton()
button.setTitle("Tag", for: .normal)
let options = ButtonOptions(
    layerColor: UIColor.black, // layer Color
    layerRadius: 6.0, // layer Radius
    layerWidth: 1.0, // layer Width
    tagTitleColor: UIColor.black, // title Color
    tagFont: UIFont.systemFont(ofSize: 15), // Font
    tagBackgroundColor: UIColor.white, // Background Color
    lineBreakMode: NSLineBreakMode.byTruncatingMiddle //break Mode
)
button.setEntity(options)
tagsView.append(button)

LastTagButton Customize

let button = TagButton()
button.setTitle("Tag", for: .normal)
let options = ButtonOptions(
    layerColor: UIColor.black, // layer Color
    layerRadius: 6.0, // layer Radius
    layerWidth: 1.0, // layer Width
    tagTitleColor: UIColor.black, // title Color
    tagFont: UIFont.systemFont(ofSize: 15), // Font
    tagBackgroundColor: UIColor.white, // Background Color
    lineBreakMode: NSLineBreakMode.byTruncatingMiddle //break Mode
)
button.setEntity(options)
tagsView.lastTagButton(TagButton())

Author

pikachu987, [email protected]

License

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

Latest podspec

{
    "name": "RxTags",
    "version": "0.1.8",
    "summary": "Dynamic Tag Append, Remove, Insert with RxSwift extension",
    "description": "dynamically add, modify, and delete tags, and you can easily change the margins, colors, and fonts of your tags.nTags are not broken because they are linked with Auto Layout.nEach time the height of the tag changes, you can bring the height to the delegate and RxSwift Observable",
    "homepage": "https://github.com/iamchiwon/Tags",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "iamchiwon": "[email protected]"
    },
    "source": {
        "git": "https://github.com/iamchiwon/Tags.git",
        "tag": "0.1.8"
    },
    "platforms": {
        "ios": "8.0"
    },
    "swift_version": "4.0",
    "source_files": "RxTags/Classes/**/*",
    "dependencies": {
        "Tags": [],
        "RxSwift": [],
        "RxCocoa": []
    }
}

Pin It on Pinterest

Share This