TagLayoutView

TagLayoutView 是一个使用 SwiftUI 构建的库,用于轻松显示标签。

Platforms License: MIT

使用方法

struct TagListView: View {
    var body: some View {
        GeometryReader { geometry in
            TagLayoutView(
            ["tagA", "tagB", "tagC"],
            tagFont: UIFont.systemFont(ofSize: 34, weight: UIFont.Weight.thin)
            padding: 20,
            parentWidth: geometry.size.width) { tag in
                Text(tag)
                .bold()
                .fixedSize()
                .padding(EdgeInsets(top: 4, leading: 12, bottom: 4, trailing: 12))
                .foregroundColor(Color.green)
                .background(Color.white)
                .overlay(RoundedRectangle(cornerRadius: 32).stroke(Color.green, lineWidth: 2.0))
            }.padding(.all, 16)
        }
    }
}

安装

TagLayoutView 可以通过 Swift Package Manager 获取。

使用 Xcode 11,转到 File -> Swift Packages -> Add Package Dependency 并输入 https://github.com/yotsu12/TagLayoutView