0

I need cells one nearby another like below

enter image description here

but i am getting like this: in short phones they are very far from one another

enter image description here

for collectionview i have given constraints:

height = 80, leading = trailing = 0, top = 20

and in viewdidload:

  override func viewDidLoad() {
    super.viewDidLoad()
    //services collectionview cell
    let serviceLayout = UICollectionViewFlowLayout()
    serviceLayout.minimumInteritemSpacing = 0
    serviceLayout.minimumLineSpacing = 0
    serviceLayout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
    self.servicesCollectionView.collectionViewLayout = serviceLayout
    servicesCollectionView.contentInsetAdjustmentBehavior = .always
    servicesCollectionView.addObserver(self, forKeyPath: "contentSize", options: .new, context: nil)
   }

i haven't given anything more then this.. please do help.. to get collectionview cells to come near to each other

  • https://dev.to/kevinmaarek/using-collectionview-compositional-layouts-in-swift-5-1nan – SPatel Apr 13 '21 at 11:26
  • Does this answer your question? [Left Align Cells in UICollectionView](https://stackoverflow.com/questions/22539979/left-align-cells-in-uicollectionview) – Βασίλης Δ. Apr 13 '21 at 11:26
  • I have gisted a CollectionViewLayout for that : https://gist.github.com/celian-m/211d1f3b442134265be6772ffcbd50e7 – CZ54 Apr 13 '21 at 14:10

0 Answers0