From e492770aed2cc2eccfc20557921deb297772ca27 Mon Sep 17 00:00:00 2001 From: Levi McCallum Date: Tue, 22 Sep 2015 21:08:50 -0700 Subject: [PATCH] Expose collection view supplementary node data source method --- AsyncDisplayKit/ASCollectionView.h | 2 ++ examples/ASCollectionView/Sample/ViewController.m | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/AsyncDisplayKit/ASCollectionView.h b/AsyncDisplayKit/ASCollectionView.h index a5b0aae9c7..7d3ea56fc9 100644 --- a/AsyncDisplayKit/ASCollectionView.h +++ b/AsyncDisplayKit/ASCollectionView.h @@ -274,6 +274,8 @@ @optional +- (ASDisplayNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath; + /** * Provides the constrained size range for measuring the node at the index path. * diff --git a/examples/ASCollectionView/Sample/ViewController.m b/examples/ASCollectionView/Sample/ViewController.m index 779f4e6666..7e97f9bb53 100644 --- a/examples/ASCollectionView/Sample/ViewController.m +++ b/examples/ASCollectionView/Sample/ViewController.m @@ -76,6 +76,17 @@ return node; } +- (ASDisplayNode *)collectionView:(ASCollectionView *)collectionView nodeForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath +{ + ASDisplayNode *node = [[ASDisplayNode alloc] init]; + if ([kind isEqualToString:UICollectionElementKindSectionHeader]) { + node.backgroundColor = [UIColor blueColor]; + } else { + node.backgroundColor = [UIColor redColor]; + } + return node; +} + - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 300;