iOS: impl font & hint font for input

This commit is contained in:
王劲鹏
2021-07-20 15:46:49 +08:00
committed by osborn
parent 04d9958a4d
commit 489fea0839
7 changed files with 39 additions and 2 deletions

View File

@@ -102,7 +102,12 @@ - (void)blendView:(DoricInputView *)view forPropName:(NSString *)name propValue:
if ([name isEqualToString:@"text"]) {
view.text = prop;
} else if ([name isEqualToString:@"textSize"]) {
view.font = [UIFont systemFontOfSize:[(NSNumber *) prop floatValue]];
UIFont *font = view.font;
if (font) {
view.font = [view.font fontWithSize:[(NSNumber *) prop floatValue]];
} else {
view.font = [UIFont systemFontOfSize:[(NSNumber *) prop floatValue]];
}
} else if ([name isEqualToString:@"textColor"]) {
view.textColor = DoricColor(prop);
} else if ([name isEqualToString:@"textAlignment"]) {
@@ -115,6 +120,11 @@ - (void)blendView:(DoricInputView *)view forPropName:(NSString *)name propValue:
}
view.textAlignment = alignment;
view.placeholderLabel.textAlignment = alignment;
} else if ([name isEqualToString:@"font"]) {
NSString *iconfont = prop;
UIFont *font = [UIFont fontWithName:[iconfont stringByReplacingOccurrencesOfString:@".ttf" withString:@""]
size:view.font.pointSize];
view.font = font;
} else if ([name isEqualToString:@"multiline"]) {
BOOL value = [(NSNumber *) prop boolValue];
if (!value) {
@@ -131,6 +141,11 @@ - (void)blendView:(DoricInputView *)view forPropName:(NSString *)name propValue:
view.placeholderLabel.text = (NSString *) prop;
} else if ([name isEqualToString:@"hintTextColor"]) {
view.placeholderLabel.textColor = DoricColor(prop);
} else if ([name isEqualToString:@"hintFont"]) {
NSString *iconfont = prop;
UIFont *font = [UIFont fontWithName:[iconfont stringByReplacingOccurrencesOfString:@".ttf" withString:@""]
size:view.font.pointSize];
view.placeholderLabel.font = font;
} else if ([name isEqualToString:@"onTextChange"]) {
if ([prop isKindOfClass:[NSString class]]) {
self.onTextChange = ^(NSString *text, DoricInputNode *node) {
@@ -227,7 +242,14 @@ - (void)afterBlended:(NSDictionary *)props {
|| self.view.doricLayout.paddingRight != self.view.textContainerInset.right) {
self.view.textContainerInset = UIEdgeInsetsMake(self.view.doricLayout.paddingTop, self.view.doricLayout.paddingLeft, self.view.doricLayout.paddingBottom, self.view.doricLayout.paddingRight);
}
self.view.placeholderLabel.font = self.view.font;
UIFont *font = self.view.placeholderLabel.font;
if (font) {
self.view.placeholderLabel.font = [self.view.placeholderLabel.font fontWithSize:self.view.font.pointSize];
} else {
self.view.placeholderLabel.font = self.view.font;
}
self.view.placeholderLabel.numberOfLines = self.view.textContainer.maximumNumberOfLines;
}