diff --git a/Libraries/Text/RCTShadowText.m b/Libraries/Text/RCTShadowText.m index 267cd2087..00770dea9 100644 --- a/Libraries/Text/RCTShadowText.m +++ b/Libraries/Text/RCTShadowText.m @@ -116,12 +116,9 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f parentProperties = [super processUpdatedProperties:applierBlocks parentProperties:parentProperties]; - UIEdgeInsets padding = self.paddingAsInsets; - CGFloat width = self.frame.size.width - (padding.left + padding.right); - - + CGFloat availableWidth = self.availableSize.width; NSNumber *parentTag = [[self reactSuperview] reactTag]; - NSTextStorage *textStorage = [self buildTextStorageForWidth:width widthMode:YGMeasureModeExactly]; + NSTextStorage *textStorage = [self buildTextStorageForWidth:availableWidth widthMode:YGMeasureModeExactly]; CGRect textFrame = [self calculateTextFrame:textStorage]; BOOL selectable = _selectable; [applierBlocks addObject:^(NSDictionary *viewRegistry) { @@ -160,7 +157,8 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f absolutePosition:(CGPoint)absolutePosition { // Run layout on subviews. - NSTextStorage *textStorage = [self buildTextStorageForWidth:self.frame.size.width widthMode:YGMeasureModeExactly]; + CGFloat availableWidth = self.availableSize.width; + NSTextStorage *textStorage = [self buildTextStorageForWidth:availableWidth widthMode:YGMeasureModeExactly]; NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject; NSTextContainer *textContainer = layoutManager.textContainers.firstObject; NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer]; @@ -480,8 +478,7 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f - (CGRect)calculateTextFrame:(NSTextStorage *)textStorage { CGRect textFrame = UIEdgeInsetsInsetRect((CGRect){CGPointZero, self.frame.size}, - self.paddingAsInsets); - + self.compoundInsets); if (_adjustsFontSizeToFit) { textFrame = [self updateStorage:textStorage toFitFrame:textFrame]; @@ -492,7 +489,6 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f - (CGRect)updateStorage:(NSTextStorage *)textStorage toFitFrame:(CGRect)frame { - BOOL fits = [self attemptScale:1.0f inStorage:textStorage forFrame:frame]; @@ -507,8 +503,8 @@ static YGSize RCTMeasure(YGNodeRef node, float width, YGMeasureMode widthMode, f requiredSize = [self calculateSize:textStorage]; } - //Vertically center draw position for new text sizing. - frame.origin.y = self.paddingAsInsets.top + RCTRoundPixelValue((CGRectGetHeight(frame) - requiredSize.height) / 2.0f); + // Vertically center draw position for new text sizing. + frame.origin.y = self.compoundInsets.top + RCTRoundPixelValue((CGRectGetHeight(frame) - requiredSize.height) / 2.0f); return frame; }