From 116469d52ce02c4f075b68d70979a48168d89626 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Thu, 9 Sep 2021 15:10:42 +0800 Subject: [PATCH] iOS: fix hintFont default is font --- doric-iOS/Pod/Classes/Shader/DoricInputNode.m | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricInputNode.m b/doric-iOS/Pod/Classes/Shader/DoricInputNode.m index c491bfca..2dc5a61b 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricInputNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricInputNode.m @@ -129,6 +129,7 @@ - (void)setTextAlignment:(NSTextAlignment)textAlignment { @interface DoricInputView () @property(nonatomic, strong) DoricMultilineInput *multiLineInput; @property(nonatomic, strong) DoricSingleLineInput *singleLineInput; +@property(nonatomic, strong) UIFont *hintFont; @end @implementation DoricInputView @@ -207,7 +208,6 @@ - (NSString *)text { - (void)setFont:(UIFont *)font { self.multiLineInput.font = font; - self.multiLineInput.placeholderLabel.font = font; self.singleLineInput.font = font; } @@ -247,13 +247,6 @@ - (NSTextAlignment)textAlignment { - (void)setHintText:(NSString *)text { self.multiLineInput.placeholderLabel.text = text; - if (text) { - self.singleLineInput.attributedPlaceholder = [[NSAttributedString alloc] - initWithString:self.multiLineInput.placeholderLabel.text - attributes:@{ - NSForegroundColorAttributeName: self.multiLineInput.placeholderLabel.textColor, - NSFontAttributeName: self.multiLineInput.placeholderLabel.font}]; - } } - (NSString *)hintText { @@ -266,24 +259,11 @@ - (NSString *)hintText { - (void)setHintTextColor:(UIColor *)color { self.multiLineInput.placeholderLabel.textColor = color; - if (self.multiLineInput.placeholderLabel.text) { - self.singleLineInput.attributedPlaceholder = [[NSAttributedString alloc] - initWithString:self.multiLineInput.placeholderLabel.text - attributes:@{ - NSForegroundColorAttributeName: self.multiLineInput.placeholderLabel.textColor, - NSFontAttributeName: self.multiLineInput.placeholderLabel.font}]; - } } - (void)setHintFont:(UIFont *)font { + _hintFont = font; self.multiLineInput.placeholderLabel.font = font; - if (self.multiLineInput.placeholderLabel.text) { - self.singleLineInput.attributedPlaceholder = [[NSAttributedString alloc] - initWithString:self.multiLineInput.placeholderLabel.text - attributes:@{ - NSForegroundColorAttributeName: self.multiLineInput.placeholderLabel.textColor, - NSFontAttributeName: self.multiLineInput.placeholderLabel.font}]; - } } - (void)setKeyboardType:(UIKeyboardType)keyboardType { @@ -471,14 +451,19 @@ - (void)blend:(NSDictionary *)props { - (void)afterBlended:(NSDictionary *)props { [super afterBlended:props]; - if (self.view.multiline) { - UIFont *font = self.view.multiLineInput.placeholderLabel.font; - if (font) { - self.view.multiLineInput.placeholderLabel.font = [self.view.multiLineInput.placeholderLabel.font fontWithSize:self.view.font.pointSize]; - } else { - self.view.multiLineInput.placeholderLabel.font = self.view.multiLineInput.font; - } - self.view.multiLineInput.placeholderLabel.numberOfLines = self.view.multiLineInput.textContainer.maximumNumberOfLines; + UIFont *font = self.view.hintFont; + if (font) { + self.view.multiLineInput.placeholderLabel.font = [self.view.multiLineInput.placeholderLabel.font fontWithSize:self.view.font.pointSize]; + } else { + self.view.multiLineInput.placeholderLabel.font = self.view.multiLineInput.font; + } + self.view.multiLineInput.placeholderLabel.numberOfLines = self.view.multiLineInput.textContainer.maximumNumberOfLines; + if (self.view.multiLineInput.placeholderLabel.text) { + self.view.singleLineInput.attributedPlaceholder = [[NSAttributedString alloc] + initWithString:self.view.multiLineInput.placeholderLabel.text + attributes:@{ + NSForegroundColorAttributeName: self.view.multiLineInput.placeholderLabel.textColor, + NSFontAttributeName: self.view.multiLineInput.placeholderLabel.font}]; } }