0
我想要做的是在沒有空間的情況下將每個視圖放在下一行。標籤庫正在使用的原理相同(認爲是這樣)。我不希望他們只是滾動到下一行並左對齊。這裏是我的代碼:使用UICollectionView和FlowLayout標籤組件?
self.collection.register(UINib(nibName: "FlowCell", bundle: nil), forCellWithReuseIdentifier: "tag")
self.collection.showsHorizontalScrollIndicator = false
self.collection.showsVerticalScrollIndicator = false
self.collection.dataSource = self
self.collection.delegate = self
let layout = collection.collectionViewLayout as! UICollectionViewFlowLayout
layout.estimatedItemSize = CGSize(width: 10, height: 18)
這是結果
- 有水平滾動方向。這裏我只有一個行:
嘗試各種不同的文字長度。它是否做同樣的事情? –