Reputation: 119
As the size of the collectionView cell grows, the cell alignment between the small screen device models (iphone 5s / se / 6/7/8) and the large screen device models (iphone 8+ / XR / XS max) changes.
Like the picture below, I want to use the above picture with cell with almost no margin of collectionView.
How can I resize the collectionView cell from device to device?
Upvotes: 1
Views: 39
Reputation: 317
optional func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize
here if you are setting the size of the collectionviewcell make the width of cell
return CGSize(width: UIScreen.main.bounds.width/ 2, height:UIScreen.main.bounds.height/2)
Please set width and height property according to your need i have only divide it by 2 for simplicity .
Upvotes: 1