Giter Club home page Giter Club logo

taglistview's Introduction

TagListView

Travis CI Version License Carthage compatible

Simple and highly customizable iOS tag list view, in Swift.

Supports Storyboard, Auto Layout, and @IBDesignable.

Screenshot

Usage

The most convenient way is to use Storyboard. Drag a view to Storyboard and set Class to TagListView (if you use CocoaPods, also set Module to TagListView). Then you can play with the attributes in the right pane, and see the preview in real time thanks to @IBDesignable.

Interface Builder

You can add tag to the tag list view, or set custom font and alignment through code:

tagListView.textFont = UIFont.systemFont(ofSize: 24)
tagListView.alignment = .center // possible values are [.leading, .trailing, .left, .center, .right]
tagListView.minWidth = 57

tagListView.addTag("TagListView")
tagListView.addTags(["Add", "two", "tags"])

tagListView.insertTag("This should be the second tag", at: 1)

tagListView.setTitle("New Title", at: 6) // to replace the title a tag

tagListView.removeTag("meow") // all tags with title “meow” will be removed
tagListView.removeAllTags()

You can implement TagListViewDelegate to receive tag pressed event:

// ...
{
    // ...
    tagListView.delegate = self
    // ...
}

func tagPressed(title: String, tagView: TagView, sender: TagListView) {
    print("Tag pressed: \(title), \(sender)")
}

You can also customize a particular tag, or set tap handler for it by manipulating the TagView object returned by addTag(_:):

let tagView = tagListView.addTag("blue")
tagView.tagBackgroundColor = UIColor.blueColor()
tagView.onTap = { tagView in
    print("Don’t tap me!")
}

Be aware that if you update a property (e.g. tagBackgroundColor) for a TagListView, all the inner TagViews will be updated.

Installation

Use CocoaPods:

pod 'TagListView', '~> 1.0'

Or Carthage:

github "ElaWorkshop/TagListView" ~> 1.0

Or drag TagListView folder into your project.

Older Swift Versions?

Currently, the master branch is using Swift 5.

For Swift 4, use version 1.3.2 or swift-4 branch. For Swift 3, use version 1.2.0 or swift-3 branch. For Swift 2, use version 1.0.1 or swift-2.3 branch. For Swift 1.2, use version 0.2.

Contribution

Pull requests are welcome! If you want to do something big, please open an issue to let me know first.

License

MIT

taglistview's People

Contributors

aaronpearce avatar aleene avatar anti-transmission avatar benuuu avatar cee avatar csvenja avatar danielgindi avatar djbe avatar gersonmdesouza avatar griffinmacias avatar joeferrucci avatar joogps avatar kajensen avatar kapizoli77 avatar kitasuke avatar krezzoid avatar marcelofabri avatar matsoftware avatar migfabio avatar morizotter avatar nick-the-uncharted avatar olejnjak avatar redent avatar ronkliffer avatar takuoka avatar toshi0383 avatar uberjason avatar uson1x avatar xbeg9 avatar xhacker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

taglistview's Issues

Edit Support

I am looking for a way for the user to add/delete/change a single tag. Is there somebody who has already implemented this? And how?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Error thrown on Xcode8 / Swift 2.3

I am using CocoaPods as package manager.
TagListVeiw version is 1.0.1

Error Info:

file:///Users/Plutonist/Documents/Project/Rider/Rider/Base.lproj/FeedView.storyboard: error: IB Designables: Failed to render and update auto layout status for FeedViewController (9pv-A4-QxB): dlopen(TagListView.framework, 1): Symbol not found: __TWPSis16ForwardIndexTypes
  Referenced from: TagListView.framework
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays/../../../../../../Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylib
 in TagListView.framework
file:///Users/Plutonist/Documents/Project/Rider/Rider/Base.lproj/FeedView.storyboard: error: IB Designables: Failed to update auto layout status: dlopen(TagListView.framework, 1): Symbol not found: __TWPSis16ForwardIndexTypes
  Referenced from: TagListView.framework
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays/../../../../../../Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylib
 in TagListView.framework

The project can be compile and running normally. But this error causing the chaotic storyboard component.
What's happened and how could I solve it? Thanks!


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

How would we center the tags?

I would like to center all the tags so we don't have all the spaces in the right of our view.
Like Flipboard for example:
img_1109

How would we get this to work??

Feature Request: Limit on Number of Displayable Rows?

For now, there is no limit on the number of rows possible.

Would you be interested in the below:

// Similar to UILabel numberOfLines, 0 means infinite
public var numberOfDisplayableRows = 0

I can create a PR, If you are happy to have this feature.

Accessories for the tags (besides X)

I'm specifically wondering about a + and - (which, in my case, are for following/unfollowing certain tags). I'm trying to replicate the tags shown in this webpage:
img_1395

more complete delegate

Can't make a clean PR for now but this should be easy to integrate :
added in TagLisViewDelegate :
@objc optional func tagListViewDidAdd(sender: TagListView, tagView: TagView) -> Void
@objc optional func tagListViewDidRemove(sender: TagListView, tagView: TagView) -> Void
@objc optional func tagListViewDidRemoveAll(sender: TagListView) -> Void

then at the end of addTagView(tagView: TagView) :
delegate?.tagListViewDidAdd?(sender : self, tagView: tagView)

then at the end of removeTagView(tagView: TagView) :
delegate?.tagListViewDidRemove?(sender : self, tagView: tagView)

then at the end of removeAllTags() :
delegate?.tagListViewDidRemoveAll?(sender : self)

So it now easy to keep track of tags title in the tagListView


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Custom text color for a specific tag

Hi,

I've tried to customise color font for a specific tag. This is my code

let tagView: TagView = tagListView.addTag("Tag Test")
tagView.textColor = tag.fontColor

but I've received this error

Value of type 'TagView' has no member 'textColor'

Could you help me, please? Like make textColor public?

Deleting tags

Hey,

I haven't downloaded or played with the code yet, but this is something I'm thinking of using very soon in my app. I was just wondering if maybe there's a way to have something like an "X" to delete and its own dedicated touch event for it?

So in other words, I'd like the user to be easily remove tags manually by pressing the "X" icon, without having to go into an "edit" mode. I was thinking of having a the "X" to the left and then to the right the normal text.

Force horizontal scrolling

Hi,
I would like to make horizontal scrollable tag list view, preferably in interface builder.
I did not manage to do it by including it in a scroll view.

Can you give me a hint ?
Thanks !


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Get specific tag ?

Hi, I really like your tagList but I have some customized requests.
I would like to add a feature that allow me to do a customized filter, like the filter selectedTags()
I think maybe you can add a public function that pass a block and then user can specify their own customized filter. e.g, I wanna pick the tag with certain titles, etc.

I can add a pull request if you want, but I am not sure whether this feature is sth you also want to do.

Not getting proper height using this.

I am using this taglist to disply multiple tags in my tableview with custom cell but am nit getting the proper height using its getting messup with other UI. please help me.
Thanks

Animations?

Hi, how can I add animation?

Example :

Tag 1 Tag 2 Tag 3

-Delete Tag 1

Tag 2 and Tag 3 fill up the space

[space] <-- Tag 2 Tag 3

very much works like collection view deleteRowAtItem

Change color of text label?

Hello, how am I able to change the color of the text in the tag when it is pressed? I've been trying to get it to work but nothing seems to work and I'm not sure why. Thanks.

Infinite loop when adding Tag

Having created a TagListView programatically, I get an infinite loop when adding a tag. This could have something to do with the fact I am implementing it in a FormViewController.

Looping through the code, it seems to be stuck between layoutSubviews, rearrageViews, and private(set) var rows = 0 { didSet { invalidateIntrinsicContentSize() } }


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Dynamic removeButton display

I'm trying to do the following :

-TagListView removeButton properties configured (enable true, line color, icon size and line width)

-Adding a tag and calling "setValue" false on "enableRemoveButton" (hides the button)

-Later (on long press gesture recognizer attached to the tag) call setvalue to true for the same property and call layoutSubviews on the TagListView
-The tag refreshes and displays some space to the right, but the button is never drawn (or more precisely it's in the right place in UI debugging, but drawrect is not called hence the "X" is never drawn)

-No way through extensions to reach the CloseButton instance (all properties private or internal)

-I've noticed this does not occur for tags that had removeButton enabled when the view controller "didLayoutSubViews" runs. However, for tags added using this technique either before (ie : viewdidload, viewwillappear) or after (on another UI event), the close "X" is never drawn when the long press is activated.

Any help ?

NSAttributedString support for tag label text coloring

Is it possible to have different colors of text within the tags? For example, have one part of the tag's text be green, while another section is black? I'm thinking an NSAttributedString would fit here.
I'm trying to replicate the tags shown in this webpage:
img_1395

tagSelectedBackgroundColor is not working

Hi ,

I am using taglist view i set the tagSelectedBackgroundColor in storyboard ,
and also it tried programtically in this way

    FilterListView.tagSelectedBackgroundColor = UIColor.redColor()

but it is not effecting.
'

I am using pod 'TagListView', '~> 1.0.1’
Please let me know why it it not working?

My requirement is my tag should be gray color when added and it should change to red color when selected.

Thanks in advance.

Ramya

With Table view issue in Swift 2.3

Hello sir

I am using tag list view in the table view. i am calculating the height of cell using UITableViewAutomaticDimension but in the case of tag list view it calculate wrong height . when i scroll down table and scroll up the table view it calculate right height. it works fine ios9 but ios10 it raise the issue


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Removing a tag with the same titles

Hi!

When I create multiple tags with the same title, and then begin to remove one of them (clicking on the tag), it leads to error "fatal error: Array index out of range".

Any ETA of Swift 3 cocoapods version?

Need cococapod for swift 3, in previous comments the author said 1 or 2 days for swift 3 version, but was like 10 days ago, any news about it?

Thx

Change tag background color by user actions

I want to set default tag bg color as gray and change it to some other color if user taps on tags. Is it possible?

I took a look at the readme and sample codes, and I understood how to change bg color for all tags, but could not find how to change color for each tag.

Could you give me advice?

BTW, This is such a great library. I really appreciate it.

Tags Pinyin input method problem--标签拼音输入法问题

The label when using Pinyin input method, found that most can only play three words, and more than three will automatically enter, seek to resolve under author

Thank you hope to get the author's reply

标签使用拼音输入法时,发现最多只能打三个字, 而且超过三个会自动enter,求作者解决下

Array of tags

Ability to add an Array of Strings ex. biggerTagListView.addTags("Inboard","Onboard","Outboard")

Tags of different colors in one block

Hey,

It would be cool to choose the color for each tag individually, rather than the entire set completely. What do you think about this?

Thank you.

Strange fatal on close button pressed

Hi I got this each time I press a close button (tried on multiple taglistviews in multiples controllers with multiples delgates) :

-[TagListView.CloseButton copyWithZone:]: unrecognized selector sent to instance 0x14522ea80
2016-11-09 23:55:23.881746 ******[2541:795563] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TagListView.CloseButton copyWithZone:]: unrecognized selector sent to instance 0x14522ea80'

Set Module of TagListView

This isn't necessarily an issue, but you may want to mention in the installation instructions that if they use Cocoapods, they need to set the Module of the UIView/TagListView in the storyboard to TagListView. I never had to do this before and the sample project didn't need it, so it took me a while to realize why I was getting the error: "Unknown class TagListView in Interface Builder file".

IB Designables: Failed to render instance of TagListView

Just upgrade to version 0.5 but some errors as below generate by Xcode.

Main.storyboard: error: IB Designables: Failed to render instance of TagListView: Rendering the view took longer than 200 ms. Your drawing code may suffer from slow performance.

Not sure if it was introduced by new version.

Thanks!

Adding a tag at a specific index ?

Hi there, thanks for your amazing work !

Is there any way to add a tag a given index ?
Because I'm using the last tag as a "add button"
So it'd be nice that when i'm done adding a new tag I can call something like that :

public func addTag(title: String, atIndex index: Int! = nil) -> TagView {

Thanks
Well I can still code it and submit a PR but i'm fairly new to this project :P

Programmatically select tag

Is it possible to programmatically select a tag? I wish to select a tag when its added if its not already contained in my array of tags. Currently the method below works when the tag is not within the array but I'm not too sure how to go about it when the tag is contained in the array. I could remove the tag, add it and use the same method below but that seems quite tedious. I was wondering if there was a better solution?

Add new tag and select

  let tagView = self.tagListView.addTag(text)
  self.tagPressed(text, tagView: tagView, sender: self.tagListView)

Programmatically select tag

  tagListView.removeTag(text)
  let tagView = self.tagListView.addTag(text)
  self.tagPressed(text, tagView: tagView, sender: self.tagListView)

Incorrect sizing in UITableViewCell depending on frame in storyboard (project attached)

Hi there,

I've noticed that the TagListView, when configured in a UITableViewCell in a storyboard, may incorrectly render with the bottom cut off depending on the size of the view controller in the storyboard. I've created a quick project to demonstrate the problem: https://github.com/UberJason/TagListViewStoryboardBug

I tried to look through the code of TagListView quickly, but nothing jumped out at me to explain the problem. Hope you might have a better idea than I do!

Add tagview from another taglistview

Hi

Is it possible to add/copy tagview from a taglistview to another taglistview now? I tried, but it just freeze and seems to be in a infinite loop eating up all memory. TagView is not conformed to nscopy so it seems I have to recreate the same tagview using all the attributes again. Any thing I missed?

Cannot subclass TagView

Can the init(title: String) initialiser be made public so that when installed via Cocoapods I am able to subclass TagView?

Swift 2.0

Got some errors on Xcode 7.0
Any plan to make it compatible with Swift 2.0?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.