gpt4 book ai didi

ios - 无法快速创建 TAGVIEW?

转载 作者:行者123 更新时间:2023-11-28 06:07:07 26 4
gpt4 key购买 nike

我有一个 Collection View 。我想将 Collection View 的单元格创建为 TAGS。我已经写了,但它不计算宽度和单元格之间的左边距。请告诉我如何改进它?

extension StoreItemCell:UICollectionViewDelegate {
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {

let width = CGSize(
return self.sizingCell!.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
}
}



override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
self.tagsCollectionView.delegate = self
self.tagsCollectionView.dataSource = self
let cellNib = UINib(nibName: Titles.CellIdentifier.TagCell, bundle: nil)
self.tagsCollectionView.register(cellNib, forCellWithReuseIdentifier: Titles.CellIdentifier.TagCell)
self.tagsCollectionView.backgroundColor = UIColor.clear
self.sizingCell = (cellNib.instantiate(withOwner: nil, options: nil) as NSArray).firstObject as! TagCell?
self.flowLayout.sectionInset = UIEdgeInsetsMake(8, 8, 8, 8)
self.flowLayout.minimumInteritemSpacing = 15
}

请告诉我如何改进它。我附上了我的设计截图。

enter image description here

最佳答案

添加这个

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let Labell : UILabel = UILabel()

Labell.text = self.TagsArray[indexPath.item] as? String
let labelTextWidth = Labell.intrinsicContentSize.width
return CGSize(width: labelTextWidth + 10, height: 30)


}

中创建 UILabel
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
}

关于ios - 无法快速创建 TAGVIEW?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47868700/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com