TagStyledView 0.3.0

TagStyledView 0.3.0

Dave Pang 维护。



  • dave.pang

TagStyledView

CI Status Version License Platform

示例

要运行示例项目,请首先克隆仓库,然后从 Example 目录中运行 pod install

需求

安装

TagStyledView 可通过 CocoaPods 获得。要安装它,只需将以下行添加到 Podfile 中。

pod 'TagStyledView'

用法

在接口构建器中设置

  1. 在标识检查器中,将布局对象的自定义类设置为 TagStyledView

    @IBOutlet weak var tagStyledView: TagStyledView!
  2. 注册一个 nib 文件以用于创建新的集合视图单元格。

    class TagCell1: UICollectionViewCell, TagStyling {
        @IBOutlet weak var tagLabel: UILabel!
    }
    
    class TagCell2: UICollectionViewCell, TagStyling {
        @IBOutlet weak var tagLabel: UILabel!
    }
    
    class TagCell3: UICollectionViewCell, TagStyling {
        @IBOutlet weak var tagLabel: UILabel!
    }
    tagStyledView.register(UINib(nibName: TagCell1.Resource.identifier, bundle: nil), forCellWithReuseIdentifier: TagCell1.Resource.identifier)
    tagStyledView.register(UINib(nibName: TagCell2.Resource.identifier, bundle: nil), forCellWithReuseIdentifier: TagCell2.Resource.identifier)
    tagStyledView.register(UINib(nibName: TagCell3.Resource.identifier, bundle: nil), forCellWithReuseIdentifier: TagCell3.Resource.identifier)

    💡 专业提示:您必须实现 TagStyling 协议。

在代码中设置

  1. 设置标签数据。

    tagStyledView.tags = ["first", "second", "third", "fourth fourth fourth fourth fourth fourth fourth", "fifth"]
  2. 自定义 TagStyledView.Options

    let options = TagStyledView.Options(sectionInset: .zero,
                                            lineSpacing: 10.0,
                                            interitemSpacing: 10.0,
                                            align: TagStyledView.Options.Alignment.left)
    tagStyledView.options = options
  3. 运行应用。

享受!😎

作者

dave.pang, [email protected]

许可证

TagStyledView 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。