From 4ed4b8ba06c2ae10d8064df30e86417f05b3d5f5 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Fri, 12 Feb 2021 13:03:47 -0600 Subject: [PATCH] Fixes misaligned ControllerInputsViewController callout views on iOS 14.5 --- .../GridCollectionViewLayout.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Delta/Components/Collection View/GridCollectionViewLayout.swift b/Delta/Components/Collection View/GridCollectionViewLayout.swift index bc91c56..4241ad2 100644 --- a/Delta/Components/Collection View/GridCollectionViewLayout.swift +++ b/Delta/Components/Collection View/GridCollectionViewLayout.swift @@ -50,6 +50,8 @@ class GridCollectionViewLayout: UICollectionViewFlowLayout return interitemSpacing } + private var cachedLayoutAttributes = [IndexPath: UICollectionViewLayoutAttributes]() + override var estimatedItemSize: CGSize { didSet { fatalError("GridCollectionViewLayout does not support self-sizing cells.") @@ -137,9 +139,24 @@ class GridCollectionViewLayout: UICollectionViewFlowLayout } } + for attributes in layoutAttributes + { + // Update cached attributes for layoutAttributesForItem(at:) + self.cachedLayoutAttributes[attributes.indexPath] = attributes + } + return layoutAttributes } + override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? + { + if let cachedAttributes = self.cachedLayoutAttributes[indexPath] + { + return cachedAttributes + } + + return super.layoutAttributesForItem(at: indexPath) + } } private extension GridCollectionViewLayout