Container size doesnt use content inset, add new APIs

Summary:
The content inset of a collection view can change at any time (as it does with our refresh control) and isn't a good measure of the container size. I don't want to totally remove that API though, so I changed the default behavior, added an insets API, and also added the functionality of the original in a new API.

This makes sizes much more deterministic.

Reviewed By: jessesquires

Differential Revision: D4800758

fbshipit-source-id: 85ce843b5b1c297cea2e2ea705fa255617cbe356
This commit is contained in:
Ryan Nystrom
2017-03-30 09:23:32 -07:00
committed by Facebook Github Bot
parent 4e9b0bb4c4
commit 623ff2a8a8
7 changed files with 101 additions and 2 deletions

View File

@@ -15,6 +15,10 @@
#import "ImageSectionController.h"
#import "PhotoCell.h"
@interface ImageSectionController () <IGListSupplementaryViewSource>
@end
@implementation ImageSectionController
#pragma mark - IGListSectionType
@@ -39,4 +43,22 @@
}
- (id<IGListSupplementaryViewSource>)supplementaryViewSource {
return self;
}
- (NSArray<NSString *> *)supportedElementKinds {
return @[UICollectionElementKindSectionFooter];
}
- (CGSize)sizeForSupplementaryViewOfKind:(NSString *)elementKind atIndex:(NSInteger)index {
return CGSizeMake(self.collectionContext.containerSize.width, 30);
}
- (UICollectionReusableView *)viewForSupplementaryElementOfKind:(NSString *)elementKind atIndex:(NSInteger)index {
UICollectionReusableView *view = [self.collectionContext dequeueReusableSupplementaryViewOfKind:elementKind forSectionController:self class:[UICollectionReusableView class] atIndex:index];
view.backgroundColor = [UIColor yellowColor];
return view;
}
@end