preferredLayoutAttributesFittingAttributes will be called in additional views if they meet the following requirements in your subclass of UICollectionViewLayout (as far as I can tell!):
- An additional view is set with a non-zero frame in
prepareLayout - Layout attributes are provided for an additional view in
layoutAttributesForSupplementaryViewOfKind:atIndexPath: - An additional view is visible according to
layoutAttributesForElementsInRect: - Finally, make sure that
elementKind matches your CollectionView collectionView:viewForSupplementaryElementOfKind:atIndexPath: when the dequeueReusableSupplementaryViewOfKind:forIndexPath: is unloaded through dequeueReusableSupplementaryViewOfKind:forIndexPath:
In short: UICollectionViewLayout is an evil beast, but if a tame should call your preferredLayoutAttributesFittingAttributes additional view.
source share