Posts

Post not yet marked as solved
0 Replies
486 Views
Hello,I am testing out some code and it looks like in iOS13 the UICollectionViewFlowLayout is not receiving the changes in the collectionView frame.Below is a sample code, in which I simply change the height of the collectionView based on the amount I scroll inthe tableview below the collectionView:ViewControllerfunc scrollViewDidScroll(_ scrollView: UIScrollView) { collectionView.collectionViewLayout.invalidateLayout() let totalScroll = scrollView.contentSize.height - scrollView.bounds.size.height let offset = (scrollView.contentOffset.y) let percentage = offset / totalScroll var frame = collectionView.frame frame.size.height = 40 - (40 * percentage) collectionView.frame = frame }CustomCollectionViewFlowLayout: UICollectionViewFlowLayoutoverride func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { let attributes = super.layoutAttributesForElements(in: rect) print(collectionView?.frame) return attributes }The print statement inside the CustomCollectionViewFlowLayout in iOS 12 and below prints out the changes in collectionView.frame correctly i.e. the height actually changes. But in iOS 13, it isn't being reflected at all.Any help anybody?
Posted
by dedmeatz.
Last updated
.