Fixed wrong placeholder size calculation in multiline text input mode (#23682)

Summary:
We have the wrong calculation of placeholder size currently, leads `contentSize` or some things inaccuracy.

[iOS] [Fixed] - Fixed wrong placeholder size calculation in multiline text input mode
Pull Request resolved: https://github.com/facebook/react-native/pull/23682

Differential Revision: D14255932

Pulled By: cpojer

fbshipit-source-id: a1f40e90fc2c848579694965da8316fae9e5c4c5
This commit is contained in:
zhongwuzw
2019-02-27 21:55:15 -08:00
committed by Facebook Github Bot
parent c2071c216e
commit 5b98adf629

View File

@@ -184,7 +184,8 @@ static UIColor *defaultPlaceholderColor()
{
UIEdgeInsets textContainerInset = self.textContainerInset;
NSString *placeholder = self.placeholder ?: @"";
CGSize placeholderSize = [placeholder sizeWithAttributes:@{NSFontAttributeName: self.font ?: defaultPlaceholderFont()}];
CGSize maxPlaceholderSize = CGSizeMake(UIEdgeInsetsInsetRect(self.bounds, textContainerInset).size.width, CGFLOAT_MAX);
CGSize placeholderSize = [placeholder boundingRectWithSize:maxPlaceholderSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: self.font ?: defaultPlaceholderFont()} context:nil].size;
placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width), RCTCeilPixelValue(placeholderSize.height));
placeholderSize.width += textContainerInset.left + textContainerInset.right;
placeholderSize.height += textContainerInset.top + textContainerInset.bottom;