From c1c483ef7de93b2c9cfda81a8ec2e6eb50b25609 Mon Sep 17 00:00:00 2001 From: Vatsal Shukla Date: Thu, 16 Nov 2017 11:14:55 +0530 Subject: [PATCH] Update for Swift4 in func prepare(), for HeaderView & FooterView's systemLayoutSizeFitting function, (line 111 to 118 and 209 to 214) 1) HorizontalFittingPriority changed from UILayoutPriority.required to UILayoutPriorityRequired 2) VerticalFittingPriority changed from UILayoutPriority..fittingSizeLevel to UILayoutPriorityFittingSizeLevel --- CollectionViewShelfLayout/CollectionViewShelfLayout.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CollectionViewShelfLayout/CollectionViewShelfLayout.swift b/CollectionViewShelfLayout/CollectionViewShelfLayout.swift index f27138b..d09e667 100644 --- a/CollectionViewShelfLayout/CollectionViewShelfLayout.swift +++ b/CollectionViewShelfLayout/CollectionViewShelfLayout.swift @@ -110,7 +110,9 @@ open class CollectionViewShelfLayout: UICollectionViewLayout { if let headerView = headerView { headerViewLayoutAttributes = CollectionViewShelfLayoutHeaderFooterViewLayoutAttributes(forDecorationViewOfKind: ShelfElementKindCollectionHeader, with: IndexPath(index: 0)) headerViewLayoutAttributes?.view = headerView - let headerViewSize = headerView.systemLayoutSizeFitting(CGSize(width: collectionViewWidth, height: 0.0), withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel) + //let headerViewSize = headerView.systemLayoutSizeFitting(CGSize(width: collectionViewWidth, height: 0.0), withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel) + let targetSize = CGSize(width: collectionViewWidth, height: 0.0) + let headerViewSize = headerView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: UILayoutPriorityRequired, verticalFittingPriority: UILayoutPriorityFittingSizeLevel) headerViewLayoutAttributes?.size = headerViewSize headerViewLayoutAttributes?.frame = CGRect(origin: CGPoint(x: collectionBounds.minX, y: currentY), size: headerViewSize) currentY += headerViewSize.height @@ -206,7 +208,7 @@ open class CollectionViewShelfLayout: UICollectionViewLayout { if let footerView = footerView { footerViewLayoutAttributes = CollectionViewShelfLayoutHeaderFooterViewLayoutAttributes(forDecorationViewOfKind: ShelfElementKindCollectionFooter, with: IndexPath(index: 0)) footerViewLayoutAttributes?.view = footerView - let footerViewSize = footerView.systemLayoutSizeFitting(CGSize(width: collectionViewWidth, height: 0.0), withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel) + let footerViewSize = footerView.systemLayoutSizeFitting(CGSize(width: collectionViewWidth, height: 0.0), withHorizontalFittingPriority: UILayoutPriorityRequired, verticalFittingPriority: UILayoutPriorityFittingSizeLevel) footerViewLayoutAttributes?.size = footerViewSize footerViewLayoutAttributes?.frame = CGRect(origin: CGPoint(x: collectionBounds.minX, y: currentY), size: footerViewSize) currentY += footerViewSize.height