Walker
Walker

Reputation: 1147

swift 3 - horizontal space between custom collection view cell

I have a custom collection view cell which I'm currently separating with a divider line that is inside of each cell.

I would like to modify this to remove the divider line and instead have a space between each of the cells. The cells take up the entire width and a dynamic height. How can I add some defined space between each of the different cells?

I have a UICollectionViewController that is displaying my cells.

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
    return 10
}

But I believe this is the wrong one because it says section. I couldn't find one that didn't as I think its removed in Swift 3.

Upvotes: 2

Views: 3651

Answers (1)

Walker
Walker

Reputation: 1147

Assigning this layout to my collection view did the trick!

let layout = UICollectionViewFlowLayout()
        layout.minimumLineSpacing = 10

Upvotes: 2

Related Questions