mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Fixed text background color
Summary: @public This fixes an issue with the containerBackgroundColor property of `<Text>` nodes, where containerBackgroundColor was being overridden by the backgroundColor. I also fixed up the example so that it demonstrates the feature more clearly. Test Plan: * Check UIExplorer text example * Run Catalyst snapshot tests and check MAdMan, Groups
This commit is contained in:
@@ -125,13 +125,13 @@ static css_dim_t RCTMeasure(void *context, float width)
|
||||
}
|
||||
|
||||
if (_color) {
|
||||
[self _addAttribute:NSForegroundColorAttributeName withValue:self.color toAttributedString:attributedString];
|
||||
[self _addAttribute:NSForegroundColorAttributeName withValue:_color toAttributedString:attributedString];
|
||||
}
|
||||
if (_isHighlighted) {
|
||||
[self _addAttribute:RCTIsHighlightedAttributeName withValue:@YES toAttributedString:attributedString];
|
||||
}
|
||||
if (_textBackgroundColor) {
|
||||
[self _addAttribute:NSBackgroundColorAttributeName withValue:self.textBackgroundColor toAttributedString:attributedString];
|
||||
[self _addAttribute:NSBackgroundColorAttributeName withValue:_textBackgroundColor toAttributedString:attributedString];
|
||||
}
|
||||
|
||||
UIFont *font = [RCTConvert UIFont:nil withFamily:fontFamily size:fontSize weight:fontWeight style:fontStyle];
|
||||
|
||||
@@ -32,6 +32,15 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)reactSetFrame:(CGRect)frame
|
||||
{
|
||||
// Text looks super weird if its frame is animated.
|
||||
// This disables the frame animation, without affecting opacity, etc.
|
||||
[UIView performWithoutAnimation:^{
|
||||
[super reactSetFrame:frame];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setTextStorage:(NSTextStorage *)textStorage
|
||||
{
|
||||
_textStorage = textStorage;
|
||||
|
||||
@@ -34,6 +34,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
#pragma mark - View properties
|
||||
|
||||
RCT_IGNORE_VIEW_PROPERTY(backgroundColor);
|
||||
RCT_REMAP_VIEW_PROPERTY(containerBackgroundColor, backgroundColor, UIColor)
|
||||
|
||||
#pragma mark - Shadow properties
|
||||
|
||||
Reference in New Issue
Block a user