为水平滚动的collectionView动态增加collectionView高度约束

时间:2021-03-12 11:43:14

标签: ios swift uicollectionview autolayout

我在滚动视图中添加了水平滚动集合视图并将高度设置为 10。我尝试使用上面的代码动态更改集合视图的高度,但单元格添加了多行我的意思就像网格视图但我需要水平滚动,不应该像网格视图那样查看,而是应该像下图一样查看单行中的项目数enter image description here

         self.hei_col_offers.constant = self.col_offers.contentSize.height
         self.view.layoutIfNeeded()

0 个答案:

没有答案