Skip to content

Commit 03bd1f4

Browse files
author
Levi McCallum
committed
Expose ASViewController's constrained size for subclass customization
1 parent 2c8626e commit 03bd1f4

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

AsyncDisplayKit/ASViewController.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,13 @@
2020

2121
- (instancetype)initWithNode:(ASDisplayNode *)node;
2222

23+
/**
24+
* The constrained size used to measure the backing node.
25+
*
26+
* @discussion Defaults to providing a size range that uses the view controller view's bounds as
27+
* both the min and max definitions. Override this method to provide a custom size range to the
28+
* backing node.
29+
*/
30+
- (ASSizeRange)nodeConstrainedSize;
31+
2332
@end

AsyncDisplayKit/ASViewController.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ - (void)loadView
4040
- (void)viewWillLayoutSubviews
4141
{
4242
[super viewWillLayoutSubviews];
43-
CGSize viewSize = self.view.bounds.size;
44-
ASSizeRange constrainedSize = ASSizeRangeMake(viewSize, viewSize);
45-
[_node measureWithSizeRange:constrainedSize];
43+
[_node measureWithSizeRange:[self nodeConstrainedSize]];
4644
}
4745

4846
- (void)viewDidLayoutSubviews
@@ -61,4 +59,12 @@ - (void)viewWillAppear:(BOOL)animated
6159
[_node recursivelyFetchData];
6260
}
6361

62+
// MARK: - Layout Helpers
63+
64+
- (ASSizeRange)nodeConstrainedSize
65+
{
66+
CGSize viewSize = self.view.bounds.size;
67+
return ASSizeRangeMake(viewSize, viewSize);
68+
}
69+
6470
@end

0 commit comments

Comments
 (0)