From 36effa011a2ba9492426ba9a032e9efdea922fac Mon Sep 17 00:00:00 2001 From: Elfred Pagan Date: Fri, 22 Mar 2024 11:31:25 -0700 Subject: [PATCH] Add bottom inset to offset calculation --- MagazineLayout/Public/MagazineLayout.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MagazineLayout/Public/MagazineLayout.swift b/MagazineLayout/Public/MagazineLayout.swift index 79bc603..c193252 100755 --- a/MagazineLayout/Public/MagazineLayout.swift +++ b/MagazineLayout/Public/MagazineLayout.swift @@ -622,9 +622,15 @@ public final class MagazineLayout: UICollectionViewLayout { // If our layout direction is bottom to top we want to adjust scroll position relative to the // bottom if case .bottomToTop = verticalLayoutDirection { + let additionalOffsetAdjustment: CGFloat + if #available(iOS 11.0, tvOS 11.0, *) { + additionalOffsetAdjustment = currentCollectionView.adjustedContentInset.bottom + } else { + additionalOffsetAdjustment = 0.0 + } invalidationContext.contentOffsetAdjustment = CGPoint( x: 0.0, - y: currentCollectionView.bounds.height - newBounds.height) + y: currentCollectionView.bounds.height - newBounds.height + additionalOffsetAdjustment) } return invalidationContext