Reputation: 347
I want to give my uicollectionview automatic height.I found this code
self.flowLayout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize
But it didn't tell what flowLayout
is,so it didn't work
Upvotes: 0
Views: 135
Reputation: 1368
You can set its height like so:
collectionView.translatesAutoresizingMaskIntoConstraints = false
collectionView.heightAnchor.constraint(equalToConstant: collectionView.contentSize.height).isActive = true
Or by setting its frame:
collectionView.frame = CGRect(x: x, y: y, width: width, height: collectionView.contentSize.height)
Upvotes: 1