Ios 使用UICollectionView和FlowLayout标记组件?
我想做的是,如果没有空间,将每个视图放在下一行。与标记库使用的原理相同(请这样想)。我不希望他们滚动只是为了在下一行和左对齐。这是我的密码:Ios 使用UICollectionView和FlowLayout标记组件?,ios,uicollectionview,uicollectionviewlayout,Ios,Uicollectionview,Uicollectionviewlayout,我想做的是,如果没有空间,将每个视图放在下一行。与标记库使用的原理相同(请这样想)。我不希望他们滚动只是为了在下一行和左对齐。这是我的密码: self.collection.register(UINib(nibName: "FlowCell", bundle: nil), forCellWithReuseIdentifier: "tag") self.collection.showsHorizontalScrollIndicator = false self.collection
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)
这就是结果
看起来正是您想要的。尝试各种不同的文本长度。它也在做同样的事情吗?