The SKTagView is a flexible and customizable tag view for iOS.
Features
- Create and display tags in a view.
- Customize tag appearance including background color, font color, corner radius, and border.
- Set a delegate to receive selection and deletion events for tags.
- Support for both single selection and multiple selection modes.
Installation
You can install SKTagView using CocoaPods by adding the following line to your Podfile:
pod 'SKTagView'
Usage
1. Import the SKTagView module in your file:
import SKTagView
2. Create an instance of SKTagView:
let tagView = SKTagView()
3. Customize the tag appearance:
tagView.backgroundColor = UIColor.white
tagView.padding = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
tagView.lineSpacing = 10
tagView.interitemSpacing = 10
tagView.preferredMaxLayoutWidth = UIScreen.main.bounds.width
...
4. Add tags to the view:
tagView.addTag("Tag 1")
tagView.addTag("Tag 2")
tagView.addTag("Tag 3")
...
5. Set the delegate to handle tag events:
tagView.delegate = self
...
extension YourViewController: SKTagViewDelegate {
func tagView(_ tagView: SKTagView, didSelectedTagAt index: Int) {
// Handle tag selection here
}
func tagView(_ tagView: SKTagView, didRemovedTagAt index: Int) {
// Handle tag deletion here
}
}
Documentation
You can find more detailed information about the API and usage examples in the official documentation.
License
SKTagView is available under the MIT license. See the LICENSE file for more info.