Hello i want to show the collectionView exactly as the above image. I know that it responsible for UICollectionViewFlowLayout, but unable to do it. Help is much appreciated. Here is my code
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let yourWidth = (collectionView.bounds.width - 4) / 3.0
let yourHeight = yourWidth
return CGSize(width: yourWidth, height: yourHeight)
}
Your answer is in your question bro some short of conditions
If this is what you are looking for than it is pretty easy to do with
UICollectionViewFlowLayout
I am using cells to be 1:1 ratio, so same width and height, you can play around with padding and item spacing and such to get desired effects.
Your controller has to conform to
UICollectionViewDelegateFlowLayout
protocolIn my test app I did the following: