mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-30 05:55:48 +08:00
Add lineHeight support of placeholder for multiline text input (#23760)
Summary: After some refactor of text input attributes, we can now add style attributes the same as text input's attributes, from https://github.com/facebook/react-native/issues/19002#issuecomment-467171589, user wants placeholder to support line-height , I think we can add it now for multiline text input. [iOS] [Added] - Added lineHeight support of placeholder for multiline text input Pull Request resolved: https://github.com/facebook/react-native/pull/23760 Differential Revision: D14320600 Pulled By: cpojer fbshipit-source-id: ededeaa11560af089ca15ffc188e2e70db2ad7d4
This commit is contained in:
committed by
Facebook Github Bot
parent
aa3b0d99f4
commit
fd954cda55
@@ -252,13 +252,20 @@ static UIColor *defaultPlaceholderColor()
|
|||||||
|
|
||||||
- (NSDictionary<NSAttributedStringKey, id> *)placeholderEffectiveTextAttributes
|
- (NSDictionary<NSAttributedStringKey, id> *)placeholderEffectiveTextAttributes
|
||||||
{
|
{
|
||||||
NSDictionary<NSAttributedStringKey, id> *effectiveTextAttributes = @{
|
NSMutableDictionary<NSAttributedStringKey, id> *effectiveTextAttributes = [NSMutableDictionary dictionaryWithDictionary:@{
|
||||||
NSFontAttributeName: _reactTextAttributes.effectiveFont ?: defaultPlaceholderFont(),
|
NSFontAttributeName: _reactTextAttributes.effectiveFont ?: defaultPlaceholderFont(),
|
||||||
NSForegroundColorAttributeName: self.placeholderColor ?: defaultPlaceholderColor(),
|
NSForegroundColorAttributeName: self.placeholderColor ?: defaultPlaceholderColor(),
|
||||||
NSKernAttributeName:isnan(_reactTextAttributes.letterSpacing) ? @0 : @(_reactTextAttributes.letterSpacing)
|
NSKernAttributeName:isnan(_reactTextAttributes.letterSpacing) ? @0 : @(_reactTextAttributes.letterSpacing)
|
||||||
};
|
}];
|
||||||
|
if (!isnan(_reactTextAttributes.lineHeight)) {
|
||||||
|
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
|
||||||
|
CGFloat lineHeight = _reactTextAttributes.lineHeight * _reactTextAttributes.effectiveFontSizeMultiplier;
|
||||||
|
paragraphStyle.minimumLineHeight = lineHeight;
|
||||||
|
paragraphStyle.maximumLineHeight = lineHeight;
|
||||||
|
effectiveTextAttributes[NSParagraphStyleAttributeName] = paragraphStyle;
|
||||||
|
}
|
||||||
|
|
||||||
return effectiveTextAttributes;
|
return [effectiveTextAttributes copy];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Utility Methods
|
#pragma mark - Utility Methods
|
||||||
|
|||||||
Reference in New Issue
Block a user