From 010d1bb0c27b330615a9aebe85ed554e8b3c8b99 Mon Sep 17 00:00:00 2001 From: Pavel Mazurin Date: Fri, 28 Jul 2017 11:39:38 +0200 Subject: [PATCH] Fixes #606 --- YogaKit/Source/YGLayout.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/YogaKit/Source/YGLayout.m b/YogaKit/Source/YGLayout.m index df4a4821..996504f3 100644 --- a/YogaKit/Source/YGLayout.m +++ b/YogaKit/Source/YGLayout.m @@ -304,10 +304,14 @@ static YGSize YGMeasureView( const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height; UIView *view = (__bridge UIView*) YGNodeGetContext(node); - const CGSize sizeThatFits = [view sizeThatFits:(CGSize) { - .width = constrainedWidth, - .height = constrainedHeight, - }]; + CGSize sizeThatFits = CGSizeZero; + + if ([view.subviews count] > 0) { + sizeThatFits = [view sizeThatFits:(CGSize) { + .width = constrainedWidth, + .height = constrainedHeight, + }]; + } return (YGSize) { .width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),