### Install TagListView with Carthage Source: https://context7.com/elaworkshop/taglistview/llms.txt Add TagListView to your project using Carthage by specifying the GitHub repository and version in your Cartfile. ```text github "ElaWorkshop/TagListView" ~> 1.4 ``` -------------------------------- ### Programmatic TagListView Setup Source: https://context7.com/elaworkshop/taglistview/llms.txt Create and configure TagListView entirely in code, including adding it to the view hierarchy and setting constraints. ```swift class ProgrammaticViewController: UIViewController, TagListViewDelegate { private var tagListView: TagListView! override func viewDidLoad() { super.viewDidLoad() // Create TagListView programmatically tagListView = TagListView() tagListView.translatesAutoresizingMaskIntoConstraints = false tagListView.delegate = self // Configure appearance tagListView.textColor = .white tagListView.tagBackgroundColor = UIColor(red: 0.2, green: 0.6, blue: 1.0, alpha: 1.0) tagListView.cornerRadius = 12 tagListView.paddingX = 15 tagListView.paddingY = 8 tagListView.marginX = 10 tagListView.marginY = 10 tagListView.textFont = UIFont.systemFont(ofSize: 16, weight: .medium) tagListView.alignment = .leading tagListView.enableRemoveButton = true // Add to view hierarchy view.addSubview(tagListView) // Setup Auto Layout constraints NSLayoutConstraint.activate([ tagListView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 20), tagListView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16), tagListView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16) ]) // Add tags tagListView.addTags(["Technology", "Design", "Development", "iOS", "Swift"]) } func tagPressed(_ title: String, tagView: TagView, sender: TagListView) { tagView.isSelected = !tagView.isSelected } func tagRemoveButtonPressed(_ title: String, tagView: TagView, sender: TagListView) { sender.removeTagView(tagView) } } ``` -------------------------------- ### Basic TagListView Setup and Usage Source: https://context7.com/elaworkshop/taglistview/llms.txt Demonstrates setting up a TagListView in a UIViewController, configuring its appearance, and adding tags. Requires conforming to the TagListViewDelegate protocol for event handling. ```swift import UIKit import TagListView class TagViewController: UIViewController, TagListViewDelegate { @IBOutlet weak var tagListView: TagListView! override func viewDidLoad() { super.viewDidLoad() // Set delegate for event handling tagListView.delegate = self // Configure appearance tagListView.textColor = .white tagListView.tagBackgroundColor = .systemBlue tagListView.textFont = UIFont.systemFont(ofSize: 14) tagListView.cornerRadius = 8 tagListView.paddingX = 10 tagListView.paddingY = 5 tagListView.marginX = 8 tagListView.marginY = 8 // Add individual tag tagListView.addTag("Swift") // Add multiple tags at once tagListView.addTags(["iOS", "UIKit", "Auto Layout"]) } // MARK: - TagListViewDelegate func tagPressed(_ title: String, tagView: TagView, sender: TagListView) { print("Tag pressed: \(title)") tagView.isSelected = !tagView.isSelected } func tagRemoveButtonPressed(_ title: String, tagView: TagView, sender: TagListView) { print("Tag removed: \(title)") sender.removeTagView(tagView) } } ``` -------------------------------- ### Install TagListView with CocoaPods Source: https://github.com/elaworkshop/taglistview/blob/master/README.md Add TagListView to your project using CocoaPods by including the specified pod in your Podfile. ```ruby pod 'TagListView', '~> 1.0' ``` -------------------------------- ### Install TagListView with Carthage Source: https://github.com/elaworkshop/taglistview/blob/master/README.md Integrate TagListView into your project using Carthage by specifying the GitHub repository and version in your Cartfile. ```ruby github "ElaWorkshop/TagListView" ~> 1.0 ``` -------------------------------- ### Install TagListView with Swift Package Manager Source: https://context7.com/elaworkshop/taglistview/llms.txt Integrate TagListView into your project using Swift Package Manager by adding the repository URL and version to your Package.swift dependencies. ```swift .package(url: "https://github.com/ElaWorkshop/TagListView.git", from: "1.4.0") ``` -------------------------------- ### Configure TagListView Properties Source: https://github.com/elaworkshop/taglistview/blob/master/README.md Set font, alignment, and minimum width for the tag list view. These properties affect all tags within the view. ```swift tagListView.textFont = UIFont.systemFont(ofSize: 24) tagListView.alignment = .center // possible values are [.leading, .trailing, .left, .center, .right] tagListView.minWidth = 57 ``` -------------------------------- ### Configure Tag Selection Appearance Source: https://context7.com/elaworkshop/taglistview/llms.txt Set the visual styles for selected tags, including text color, background color, and border color. ```swift tagListView.selectedTextColor = .white tagListView.tagSelectedBackgroundColor = .systemGreen tagListView.selectedBorderColor = .systemGreen ``` -------------------------------- ### Add and Insert Tags Source: https://github.com/elaworkshop/taglistview/blob/master/README.md Add single tags or multiple tags at once. Tags can also be inserted at a specific index. ```swift tagListView.addTag("TagListView") tagListView.addTags(["Add", "two", "tags"]) tagListView.insertTag("This should be the second tag", at: 1) ``` -------------------------------- ### Configure Remove Button Source: https://context7.com/elaworkshop/taglistview/llms.txt Enable and customize the remove button on tags. Implement the delegate method to handle removal. ```swift tagListView.enableRemoveButton = true ``` ```swift tagListView.removeButtonIconSize = 14 tagListView.removeIconLineWidth = 2 tagListView.removeIconLineColor = UIColor.white.withAlphaComponent(0.8) ``` ```swift func tagRemoveButtonPressed(_ title: String, tagView: TagView, sender: TagListView) { // Perform removal with animation UIView.animate(withDuration: 0.3) { tagView.alpha = 0 } completion: { _ in sender.removeTagView(tagView) } } ``` -------------------------------- ### Handle Tag Selection and Removal Source: https://context7.com/elaworkshop/taglistview/llms.txt Implement delegate methods to toggle selection state and handle remove button presses. Retrieve all selected tags. ```swift func tagPressed(_ title: String, tagView: TagView, sender: TagListView) { tagView.isSelected = !tagView.isSelected // Get all currently selected tags let selectedTags = sender.selectedTags() let selectedTitles = selectedTags.compactMap { $0.currentTitle } print("Selected tags: \(selectedTitles)") } ``` ```swift tagListView.tagViews.forEach { $0.isSelected = false } // Deselect all tagListView.tagViews.first?.isSelected = true // Select first tag ``` -------------------------------- ### Tag Styling Properties Source: https://context7.com/elaworkshop/taglistview/llms.txt Details various properties for styling tags within TagListView, including colors, borders, spacing, fonts, text truncation, and shadows. These settings apply to all tags. ```swift // Colors tagListView.textColor = .white tagListView.selectedTextColor = .black tagListView.tagBackgroundColor = .systemBlue tagListView.tagHighlightedBackgroundColor = .systemBlue.withAlphaComponent(0.7) tagListView.tagSelectedBackgroundColor = .systemYellow // Border tagListView.cornerRadius = 10 tagListView.borderWidth = 1 tagListView.borderColor = .systemGray tagListView.selectedBorderColor = .systemOrange // Spacing tagListView.paddingX = 12 // Horizontal padding inside tag tagListView.paddingY = 6 // Vertical padding inside tag tagListView.marginX = 8 // Horizontal spacing between tags tagListView.marginY = 8 // Vertical spacing between rows tagListView.minWidth = 50 // Minimum tag width // Font tagListView.textFont = UIFont.boldSystemFont(ofSize: 16) // Text truncation tagListView.tagLineBreakMode = .byTruncatingTail // Shadow tagListView.shadowColor = .black tagListView.shadowRadius = 3 tagListView.shadowOffset = CGSize(width: 1, height: 2) tagListView.shadowOpacity = 0.3 ``` -------------------------------- ### Customize Individual TagView Source: https://context7.com/elaworkshop/taglistview/llms.txt Customize the appearance and behavior of individual tags. Tap and long press handlers can be set. ```swift let specialTag = tagListView.addTag("Featured") specialTag.tagBackgroundColor = .systemOrange specialTag.textColor = .black specialTag.cornerRadius = 15 specialTag.borderWidth = 2 specialTag.borderColor = .systemYellow specialTag.textFont = UIFont.boldSystemFont(ofSize: 18) ``` ```swift specialTag.onTap = { tagView in print("Special tag tapped: \(tagView.currentTitle ?? \"\")") // Custom action } ``` ```swift specialTag.onLongPress = { tagView in print("Long pressed: \(tagView.currentTitle ?? \"\")") // Show context menu or additional options } ``` ```swift specialTag.isSelected = true ``` ```swift specialTag.enableRemoveButton = true specialTag.removeButtonIconSize = 10 specialTag.removeIconLineColor = .darkGray ``` -------------------------------- ### Adding Tags to TagListView Source: https://context7.com/elaworkshop/taglistview/llms.txt Provides methods for adding single tags, multiple tags, inserting tags at specific positions, and adding custom TagView instances. The `addTag(_:)` method returns a TagView for further customization. ```swift // Add a single tag and get reference for customization let tagView = tagListView.addTag("Important") tagView.tagBackgroundColor = .systemRed tagView.textColor = .white // Add multiple tags at once let tagViews = tagListView.addTags(["Work", "Personal", "Urgent"]) // Insert tag at specific position (0-indexed) tagListView.insertTag("Priority", at: 0) // Add custom TagView instance let customTag = TagView(title: "Custom") customTag.cornerRadius = 15 customTag.borderWidth = 2 customTag.borderColor = .systemPurple tagListView.addTagView(customTag) ``` -------------------------------- ### Removing Tags from TagListView Source: https://context7.com/elaworkshop/taglistview/llms.txt Illustrates different ways to remove tags, including by title, by TagView reference, and removing all tags. Also shows how to update a tag's title at a specific index. ```swift // Remove all tags with matching title tagListView.removeTag("Completed") // Remove specific TagView instance if let tagToRemove = tagListView.tagViews.first { tagListView.removeTagView(tagToRemove) } // Remove all tags tagListView.removeAllTags() // Update tag title at specific index tagListView.setTitle("Updated Title", at: 0) ``` -------------------------------- ### Configure Tag Alignment Source: https://context7.com/elaworkshop/taglistview/llms.txt Set the alignment of tags within the TagListView. Defaults to .left for LTR languages. ```swift tagListView.alignment = .left ``` ```swift tagListView.alignment = .center ``` ```swift tagListView.alignment = .right ``` ```swift tagListView.alignment = .leading ``` ```swift tagListView.alignment = .trailing ``` -------------------------------- ### Implement TagListViewDelegate Source: https://github.com/elaworkshop/taglistview/blob/master/README.md Set the delegate for the TagListView to receive callbacks when a tag is pressed. The delegate method provides the tag's title, the TagView object, and the sender TagListView. ```swift // ... { // ... tagListView.delegate = self // ... } func tagPressed(title: String, tagView: TagView, sender: TagListView) { print("Tag pressed: \(title), \(sender)") } ``` -------------------------------- ### Update and Remove Tags Source: https://github.com/elaworkshop/taglistview/blob/master/README.md Modify the title of an existing tag by its index or remove tags by their title. All tags matching the title will be removed. ```swift 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() ``` -------------------------------- ### Customize Individual Tag Appearance and Tap Handler Source: https://github.com/elaworkshop/taglistview/blob/master/README.md Customize the background color of a specific tag and define a custom tap handler for it. Note that updating properties on the TagListView itself will update all inner TagViews. ```swift let tagView = tagListView.addTag("blue") tagView.tagBackgroundColor = UIColor.blueColor() tagView.onTap = { tagView in print("Don’t tap me!") } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.