diff --git a/YogaKit/Source/YGLayout.h b/YogaKit/Source/YGLayout.h index 5d6ace7d..416de203 100644 --- a/YogaKit/Source/YGLayout.h +++ b/YogaKit/Source/YGLayout.h @@ -120,6 +120,12 @@ typedef NS_OPTIONS(NSInteger, YGDimensionFlexibility) { */ @property (nonatomic, readonly, assign) CGSize intrinsicSize; +/** + Returns the size of the view based on provided constraints. Pass NaN for an unconstrained dimension. + */ +- (CGSize)calculateLayoutWithSize:(CGSize)size + NS_SWIFT_NAME(calculateLayout(with:)); + /** Returns the number of children that are using Flexbox. */ diff --git a/YogaKit/Source/YGLayout.m b/YogaKit/Source/YGLayout.m index b48d5e49..df4a4821 100644 --- a/YogaKit/Source/YGLayout.m +++ b/YogaKit/Source/YGLayout.m @@ -271,8 +271,6 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio) return [self calculateLayoutWithSize:constrainedSize]; } -#pragma mark - Private - - (CGSize)calculateLayoutWithSize:(CGSize)size { NSAssert([NSThread isMainThread], @"Yoga calculation must be done on main."); @@ -293,6 +291,8 @@ YG_PROPERTY(CGFloat, aspectRatio, AspectRatio) }; } +#pragma mark - Private + static YGSize YGMeasureView( YGNodeRef node, float width,