When creating a UICollectionVIew using Compositional Layout, the collection view's content offset changes whenever the trait collection changes, without being instructed by code. Also, the content size is changed unexpectedly. Here's the snippet of code for the section which appears to be causing the issues:
Code Block func createNotificationSection() -> NSCollectionLayoutSection { let isWide = self.bounds.width > 500 let inset: CGFloat = isWide ? 10 : 8 let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),heightDimension: .fractionalHeight(1)) let item = NSCollectionLayoutItem(layoutSize: itemSize) // item.contentInsets = NSDirectionalEdgeInsets(top: 20, leading: 8, bottom: 8, trailing: 8) let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(isWide ? 0.475 : 0.85),heightDimension: .estimated(90))//(isWide ? 125 : 100) + 90)) let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) group.interItemSpacing = .fixed(inset) group.contentInsets = NSDirectionalEdgeInsets(top: 90, leading: 0, bottom: inset, trailing: 0) let section = NSCollectionLayoutSection(group: group) section.interGroupSpacing = inset section.orthogonalScrollingBehavior = .groupPagingCentered return section }