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:
Nick Lockwood
2015-05-28 09:29:27 -07:00
parent 656c5e4e27
commit 45c1dc1c65
11 changed files with 48 additions and 40 deletions

View File

@@ -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];

View File

@@ -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;

View File

@@ -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