TagsGridView: A simple view for your tags.
Requirements
- iOS 14, macOS 10.15
- Swift 5.5
- Xcode 12.5+
Installation
The preferred way of installing SwiftUIX is via the Swift Package Manager.
Xcode 12 integrates with libSwiftPM to provide support for iOS, watchOS, macOS and tvOS platforms.
- In Xcode, open your project and navigate to File → Swift Packages → Add Package Dependency...
- Paste the repository URL (
https://github.com/alexwillrock/TagsGridView
) and click Next. - For Rules, select Branch (with branch set to
master
). - Click Finish.
Contents
Prepare view model
struct Tag: Hashable {
let title: String
let color: Color
}
Draw tag view
struct TagView: View {
let tag: Tag
var body: some View {
Text(tag.title)
.lineLimit(1)
.font(.caption2)
.padding(.all, 6)
.background {
RoundedRectangle(cornerRadius: 8)
.foregroundColor(tag.color)
}
}
}
Implemente TagsGridView
var body: some View {
HStack {
Spacer()
TagsGridView(data: tags,
spacing: 4,
alignment: .leading) { item in
TagView(tag: item)
.frame(height: 25)
}
Spacer()
}
}
Visual
License
TagsGridView is licensed under the MIT License.
Support
Credits
TagsGridView is a project of @alexwillrock.