How to set the separator inset to zero to get rid of the space?

953 Views Asked by At

I'm working on the collection view list cell and have a question about getting rid of the left side space of the separator layout guide.

enter image description here

I want to get rid of the small margin for the separator layout guide in the above image. Even though I'm using the collection view list cell, I saw there is a method for adjusting the size of the separator inset for the "tableView". Like,

tableView.separatorInset = .zero

But there is no method for the collection view, so I'm guessing maybe I can do the similar stuff when I configure the collection view list layout, because using showsSeparators property allows the cell to hide the separator. (I know I don't want to hide the separator, but I think I can configure the separator in here.)

func setupCollectionView() {

    var layoutConfig = UICollectionLayoutListConfiguration(appearance: .insetGrouped)

// layoutConfig.showsSeparators = false // -> I confirmed that I can hide the separator using this property.

    let listLayout = UICollectionViewCompositionalLayout.list(using: layoutConfig)
    collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: listLayout)
    view.addSubview(collectionView)

    collectionView.translatesAutoresizingMaskIntoConstraints = false
    NSLayoutConstraint.activate([
        // setup constraints in here...
    ])
}

Also, my app is available on iOS14, so I cannot use some other properties like separatorConfiguration.

Does anyone know how to get rid of the left space for the separator guide, which is also available in iOS 14?

Thank you in advance.

0

There are 0 best solutions below