Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Басалаев Александр committed Jun 2, 2021
2 parents 6994d5b + 0072322 commit 0503b4c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion IBPCollectionViewCompositionalLayout.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'IBPCollectionViewCompositionalLayout'
s.version = '0.6.7'
s.version = '0.6.9'
s.summary = 'Backport of UICollectionViewCompositionalLayout to earlier iOS 12.'
s.description = <<-DESC
A new UICollectionViewCompositionalLayout class has been added to UIKit to make it incredibly easier to create custom complex collection view layout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ - (void)prepareLayout {
return;
}

if (!self.collectionViewDelegate && collectionView.delegate != self) {
if (collectionView.collectionViewLayout == self && !self.collectionViewDelegate && collectionView.delegate != self) {
self.collectionViewDelegate = collectionView.delegate;
collectionView.delegate = self;
}
Expand All @@ -145,7 +145,7 @@ - (void)prepareLayout {

UIEdgeInsets collectionContentInset = UIEdgeInsetsZero;
if (@available(iOS 11.0, *)) {
if ([collectionView respondsToSelector:@selector(safeAreaInsets)]) {
if ([collectionView respondsToSelector:@selector(safeAreaInsets)] && collectionView.contentInsetAdjustmentBehavior != UIScrollViewContentInsetAdjustmentNever) {
collectionContentInset = collectionView.safeAreaInsets;
}
}
Expand Down Expand Up @@ -527,7 +527,51 @@ - (UICollectionViewLayoutAttributes *)prepareLayoutForBoundaryItem:(IBPNSCollect
withIndexPath:indexPath];
IBPNSCollectionLayoutContainer *itemContainer = [[IBPNSCollectionLayoutContainer alloc] initWithContentSize:containerFrame.size
contentInsets:IBPNSDirectionalEdgeInsetsZero];
CGSize itemSize = [boundaryItem.layoutSize effectiveSizeForContainer:itemContainer];
IBPNSCollectionLayoutSize *layoutSize = boundaryItem.layoutSize;
CGSize itemSize;

if (layoutSize.heightDimension.isEstimated || layoutSize.widthDimension.isEstimated) {
UICollectionReusableView *view = [self.collectionView.dataSource collectionView:self.collectionView
viewForSupplementaryElementOfKind:boundaryItem.elementKind
atIndexPath:indexPath];

if (view) {
CGSize containerSize = self.collectionViewContentSize;

if (!layoutSize.widthDimension.isEstimated) {
containerSize.width = CGRectGetWidth(containerFrame);
}
if (!layoutSize.heightDimension.isEstimated) {
containerSize.height = CGRectGetHeight(containerFrame);
}

CGFloat containerWidth = containerSize.width;
CGFloat containerHeight = containerSize.height;

CGRect viewFrame = view.frame;
viewFrame.size = containerSize;
view.frame = viewFrame;
[view setNeedsLayout];
[view layoutIfNeeded];

CGSize fitSize;
if (layoutSize.widthDimension.isEstimated) {
fitSize = [view systemLayoutSizeFittingSize:containerSize
withHorizontalFittingPriority:UILayoutPriorityFittingSizeLevel
verticalFittingPriority:UILayoutPriorityRequired];
fitSize.height = containerHeight;
} else {
fitSize = [view systemLayoutSizeFittingSize:containerSize
withHorizontalFittingPriority:UILayoutPriorityRequired
verticalFittingPriority:UILayoutPriorityFittingSizeLevel];
fitSize.width = containerWidth;
}

itemSize = fitSize;
}
} else {
itemSize = [boundaryItem.layoutSize effectiveSizeForContainer:itemContainer];
}

IBPNSCollectionLayoutAnchor *containerAnchor;
switch (boundaryItem.alignment) {
Expand Down Expand Up @@ -846,7 +890,7 @@ - (void)scrollViewDidChangeAdjustedContentInset:(UIScrollView *)scrollView API_A
}

- (BOOL)respondsToSelector:(SEL)aSelector {
return [self.collectionViewDelegate respondsToSelector:aSelector] || [super respondsToSelector:aSelector];
return [self.collectionViewDelegate respondsToSelector:aSelector] || [UICollectionViewLayout instancesRespondToSelector:aSelector];
}

- (void)forwardInvocation:(NSInvocation *)anInvocation {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.6.7</string>
<string>0.6.9</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down

0 comments on commit 0503b4c

Please sign in to comment.