A lightweight label class, adaptive height, width.
pod 'LJTagsView'
tagsView0.backgroundColor = .brown
tagsView0.tagsViewDelegate = self
tagsView0.tagsViewContentInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
tagsView0.tagsViewMinHeight = 40
tagsView0.scrollDirection = .horizontal
tagsView0.tagsViewMaxHeight = 300
tagsView0.minimumLineSpacing = 30;
tagsView0.minimumInteritemSpacing = 30;
self.view.addSubview(tagsView0)
tagsView0.snp.makeConstraints { (make) in
make.top.equalToSuperview().offset(150)
make.left.equalToSuperview().offset(0)
make.width.equalTo(414)
}
tagsView0.dataSource = ["Listing ID","Tower","Sole Agency Type","Have Keys","New Development","Tags","Big landlord","Street Address","Currency","Price per unit","Price per unit(Gross)","Price per unit(Saleable)","Size(Gross)","Size(Saleable)","Status","Register","Landlord","SSD","Agent","Floor Alias","Unit Alias","Unit Balcony","Tower Type","Building Age","Segment","Car Park","Is Coop","SPV","Pet Friendly","View Type","Property Type"]
// 最后reload
tagsView0.reloadData()
/** 设置每个tag的属性,包含UI ,对应的属性*/
func tagsViewUpdatePropertyModel(_ tagsView: LJTagsView, item: TagsPropertyModel, index: NSInteger) {
item.contentView.backgroundColor = UIColor.darkGray
item.contentInset = UIEdgeInsets(top: 5, left: 10, bottom: 5, right: 10)
item.normalImage = UIImage(named: "select_not")
item.selectIedImage = UIImage(named: "selected")
item.imageSize = CGSize(width: 10, height: 10)
item.imageAlignmentMode = .left
}
// 点击事情
func tagsViewItemTapAction(_ tagsView: LJTagsView, item: TagsPropertyModel, index: NSInteger) {
// 删除事件
dataSource.remove(at: index)
tagsView.dataSource.remove(at: index)
tagsView.reloadData()
}
// 返回高度
func tagsViewUpdateHeight(_ tagsView: LJTagsView, sumHeight: CGFloat) {
// do something
}