-3

my collectionview starts out like this: initial screen

when the user swipes up on the collection it expands like so: second screen

how can I change the size of the cells when the collection view expands?

Community
  • 1
  • 1
QusaiSaif
  • 3
  • 2
  • 3
    Possible duplicate of [How to change UICollectionViewCell size programmatically in Swift?](https://stackoverflow.com/questions/31662155/how-to-change-uicollectionviewcell-size-programmatically-in-swift) – Ahmad F Nov 01 '17 at 14:38

1 Answers1

0

In english:

You need to set the cells' height equals to the collection view height, and every time the collection resize you need to refresh the layout.

In iOS language

you need to conform your view controller the the UICollectionViewDelegateFlowLayout

and use the

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize

to resize the cells

extension YourViewController: UICollectionViewDelegateFlowLayout {

  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {


        let height = collectionView.frame.size.height
        let width = //make your calculation

        return  CGSize(width: width, height: height)
  }
}

something like this

Andrea Miotto
  • 7,084
  • 8
  • 45
  • 70