TagCloud 🏷️
TagCloud is a powerful, flexible and stylish package for integrating tag clouds into your iOS apps. From basic setups to fully customizable collections with your custom views, TagCloud provides an intuitive interface that blends seamlessly with SwiftUI's design paradigms.
TagCloudView
.RandomAccessCollection
and create your own custom views.Using the Swift Package Manager, add TagCloud as a dependency to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/yarspirin/TagCloud.git", .upToNextMajor(from: "1.0.0"))
]
TagCloudView
For a quick and beautiful tag cloud, simply provide an array of strings. TagCloud will use the default TagView
to generate a standard tag cloud:
import SwiftUI
import TagCloud
struct DefaultExampleView: View {
let tags = ["Hello", "World", "I", "love", "Swift", "and", "tag", "clouds"]
var body: some View {
TagCloudView(tags: tags)
}
}
TagCloudView
For more advanced usage, TagCloud allows you to fully customize the tag cloud. You can provide your own collection of data and a closure to generate custom views from your data:
import SwiftUI
import TagCloud
struct SelectableTag: View {
@State var isSelected = false
let title: String
var body: some View {
Button {
isSelected.toggle()
} label: {
Text(title)
.foregroundColor(isSelected ? .white : .black)
.padding(EdgeInsets(top: 5, leading: 10, bottom: 5, trailing: 10))
.background(
RoundedRectangle(cornerRadius: 10)
.foregroundColor(isSelected ? .black : .white)
)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(isSelected ? .white : .black, lineWidth: 1)
)
}
}
}
struct CustomExampleView: View {
let titles = ["Hello", "World", "I", "Love", "Swift", "And", "Tag", "Clouds"]
var body: some View {
TagCloudView(data: titles) { title in
SelectableTag(title: title)
}
}
}
We love contributions! Whether it's fixing bugs, improving documentation, or proposing new features, your efforts are welcome.
Author: yarspirin
Source Code: https://github.com/yarspirin/TagCloud
License: MIT license.