diff --git a/Libraries/Text/Text/RCTTextShadowView.m b/Libraries/Text/Text/RCTTextShadowView.m index d1baf9ccb..a3b0b59c3 100644 --- a/Libraries/Text/Text/RCTTextShadowView.m +++ b/Libraries/Text/Text/RCTTextShadowView.m @@ -35,6 +35,19 @@ return self; } +- (void)didSetProps:(NSArray *)changedProps +{ + [super didSetProps:changedProps]; + + // When applying a semi-transparent background color to Text component + // we must set the root text nodes text attribute background color to nil + // because the background color is drawn on the RCTTextView itself, as well + // as on the glphy background draw step. By setting this to nil, we allow + // the RCTTextView backgroundColor to be used, without affecting nested Text + // components. + self.textAttributes.backgroundColor = nil; +} + - (BOOL)isYogaLeafNode { return YES; diff --git a/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testTextExample_1-iOS12@2x.png b/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testTextExample_1-iOS12@2x.png index 600673dc5..521fe7e3e 100644 Binary files a/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testTextExample_1-iOS12@2x.png and b/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testTextExample_1-iOS12@2x.png differ diff --git a/RNTester/js/TextExample.ios.js b/RNTester/js/TextExample.ios.js index c5a8c0aa9..076458989 100644 --- a/RNTester/js/TextExample.ios.js +++ b/RNTester/js/TextExample.ios.js @@ -434,6 +434,19 @@ exports.examples = [ return {'test🙃'.substring(0, 5)}; }, }, + { + title: 'Transparent Background Color', + render: function() { + return ( + + Text in a gray box! + + Another text in a (inline) red box (which is inside the gray box). + + + ); + }, + }, { title: 'Text metrics', render: function() {