TagListView is a customizable tag list view library written in Swift. This library allows you to easily display a list of tags in your iOS app, providing a user-friendly way for users to select multiple tags.
Features
- Create a tag list view with a single line of code
- Customize the appearance of tags
- Support for selecting and highlighting tags
- Enable/disable user interaction for tags
- Handle tag tap events with ease
Installation
To install TagListView using CocoaPods, add the following line to your Podfile:
pod 'TagListView'
Then, run pod install
from the command line.
Getting Started
Follow the steps below to start using TagListView in your project:
- Import the TagListView module in your Swift file:
import TagListView
- Add a
TagListView
to your view hierarchy either programmatically or using Interface Builder:
var tagListView = TagListView(frame: CGRect(x: 20, y: 20, width: 200, height: 30))
view.addSubview(tagListView)
- Add tags to the
TagListView
using theaddTag
method:
tagListView.addTag("Tag 1")
- Implement the tag tap event handler, if needed:
tagListView.onTagTapped = { tagView in
// Handle tag tap event
}
Customization
You can customize various aspects of the TagListView
, such as font, text color, background color, and more.
- Change the font:
tagListView.textFont = UIFont.systemFont(ofSize: 14)
- Change the text color:
tagListView.textColor = UIColor.white
- Change the background color:
tagListView.tagBackgroundColor = UIColor.blue
- Show/hide horizontal scroll indicators:
tagListView.showsHorizontalScrollIndicator = false
Interaction
You can enable or disable user interaction for the TagListView
.
- Disable user interaction:
tagListView.isUserInteractionEnabled = false
Once user interaction is disabled, tags cannot be tapped or selected.
Delegate Methods
The TagListViewDelegate
protocol provides delegate methods for handling tag interactions.
func tagPressed(_ title: String, tagView: TagView, sender: TagListView)
: Called when a tag is tapped.
Implement this method in your view controller to perform the desired action when a tag is tapped.