Reputation: 127
I have a collection view.I need to display cells with varying width at sequences. First 4 cells get displayed as required but after that consecutive 5th image disappears and others are displayed but not in the desired manner. But it doesnot show in the simulator. The view gets distorted when scrolling the collection view.Please anyone help me out in swift 3.
Upvotes: 0
Views: 289
Reputation: 2668
If you want to resize UICollectionViewCell
try to implement this method, setting frame
inside cellForRowAt
is wrong.
func collectionView(_ collectionView: UICollectionView!, layout _: UICollectionViewLayout!, sizeForItemAtIndexPath indexPath: IndexPath!) -> CGSize {
if indexPath.row%3 == 0 {
return CGSize(width: 172, height: 120)
} else {
.....
}//switch, if, whatever
}
Upvotes: 1