List Layout Collection View contentOffset starts from minus

List is displayed in CollectionView with reference to Create a Simple List Layoutin page link in Implementing Modern Collection Views.

This is the implementation in the sample code.scrollViewDidScroll to display contentOffset.

import UIKit

class SimpleListViewController: UIViewController {

    enum Section {
        case main

    var dataSource: UICollectionViewDiffableDataSource<Section, Int>! = nil
    var collectionView: UICollectionView! = nil

    override func viewDidLoad() {
        navigationItem.title = "List"

extension SimpleListViewController {
    /// - Tag: List
    private func createLayout() -> UICollectionViewLayout {
        let config = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
        return UICollectionViewCompositionalLayout.list(using: config)

extension SimpleListViewController {
    private func configureHierarchy() {
        collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: createLayout())
        collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        collectionView.delegate = self
    private func configureDataSource() {
        let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, Int> { (cell, indexPath, item) in
            var content = cell.defaultContentConfiguration()
            content.text = "\(item)"
            cell.contentConfiguration = content
        dataSource = UICollectionViewDiffableDataSource<Section, Int>(collectionView: collectionView) {
            (collectionView: UICollectionView, indexPath: IndexPath, identifier: Int) -> UICollectionViewCell? in
            return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: identifier)

        // initial data
        var snapshot = NSDiffableDataSourceSnapshot<Section, Int>()
        dataSource.apply(snapshot, animatingDifferences: false)

extension SimpleListViewController: UICollectionViewDelegate {
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        collectionView.deselectItem(at: indexPath, animated: true)

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        print("## - Display scrolling contentOffset.y")

It was assumed to start from 0, but the result started with a negative value.

## - Display scrolling contentOffset.y

Please help if you know why. Thanks.

We found that scrollViewbounds.y is a negative value. Not sure of the cause...