I want to show images in a collection view in a grid format in varying sizes with a plus sign (i.e. +2,+3 etc.). It'll look like so...
I came to know that using UICollectionViewFlowLayout
this can be achieved. So I referred to this Stack Overflow question and tried adding this line of code. But it didn't work
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
switch indexPath.item {
case 0,1:
return CGSize(width: (UIScreen.main.bounds.width - 16) / 2, height: (UIScreen.main.bounds.width - 16) / 2)
default:
return CGSize(width: (UIScreen.main.bounds.width - 32) / 3, height: (UIScreen.main.bounds.width) / 3)
}
}
Also, if the number of images selected is 2 or 3, then those images should be arranged like so..
How can I make the images appear like that...?