In a CollectionView
, some cells should have an additional subview or layer. The CollectionView
can be told to resize it\'s cells, thus all content
@Alfie Hanssen solution (here) didn't work properly for me, according with this article:
The size of the cell view in the XIB is 50 x 50 points, which is the default size of the collection view cells as set in the flow layout. Even if it’s a bit hard to work with a cell this small in Interface Builder, it’s better to not change the default size. The problem is that Auto Layout considers the manually set size as being fixed and generates a NSAutoresizingMaskLayoutConstraint error when it tries to adjust the cells height automatically
I have inspected the UICollectionViewCell and I found that there is a view between the cell and the contentView, and that view has intrinsic width and height constraints. Instead of the AutoresizingMask I'm just updating as below and seems working for me.
override func layoutSubviews() {
contentView.superview?.frame = bounds
super.layoutSubviews()
}