Romy
Romy

Reputation: 538

How to prevent UICollectionView to overlap

I have this problem when I created too many folders into my app.

The folders overlap on other UI elements

This is the normal view

If instead, I scroll this what happened

enter image description here

I need to stop the scroll and not overlap the other elements

This is my code

 func collectionView(_: UICollectionView, layout _: UICollectionViewLayout, insetForSectionAt _: Int) -> UIEdgeInsets {
    return UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0)
}

func collectionView(_: UICollectionView, layout _: UICollectionViewLayout, minimumLineSpacingForSectionAt _: Int) -> CGFloat {
    return 10.0
}

func collectionView(_: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt _: IndexPath) -> CGSize {
    return CGSize(width: UIScreen.main.bounds.size.width, height: 70)
}

func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
    return arrItems.count
}

The Constrains

enter image description here

You can see my constraints to the left

Thanks In advance

Upvotes: 0

Views: 306

Answers (1)

GuangZhe Li
GuangZhe Li

Reputation: 36

Check the field "Clip to Bounds" in the UICollectionView's Attribute Inspector in the "View" section.

UICollectionview overlap

Upvotes: 2

Related Questions