@@ -913,13 +913,21 @@ static void RCTAddContourEffectToLayer(
913913 [layer removeAllAnimations ];
914914}
915915
916- static RCTBorderColors RCTCreateRCTBorderColorsFromBorderColors (BorderColors borderColors)
916+ // CALayer colors are plain CGColors: converting a dynamic (PlatformColor /
917+ // DynamicColorIOS) UIColor without an explicit trait collection resolves against
918+ // UITraitCollection.currentTraitCollection, which tracks the system appearance
919+ // and ignores any overrideUserInterfaceStyle inherited by the view. Resolve
920+ // against the view's own trait collection instead, matching the backgroundColor
921+ // handling in invalidateLayer.
922+ static RCTBorderColors RCTCreateRCTBorderColorsFromBorderColors (
923+ BorderColors borderColors,
924+ UITraitCollection *traitCollection)
917925{
918926 return RCTBorderColors{
919- .top = RCTUIColorFromSharedColor (borderColors.top ),
920- .left = RCTUIColorFromSharedColor (borderColors.left ),
921- .bottom = RCTUIColorFromSharedColor (borderColors.bottom ),
922- .right = RCTUIColorFromSharedColor (borderColors.right )};
927+ .top = [ RCTUIColorFromSharedColor (borderColors.top) resolvedColorWithTraitCollection: traitCollection] ,
928+ .left = [ RCTUIColorFromSharedColor (borderColors.left) resolvedColorWithTraitCollection: traitCollection] ,
929+ .bottom = [ RCTUIColorFromSharedColor (borderColors.bottom) resolvedColorWithTraitCollection: traitCollection] ,
930+ .right = [ RCTUIColorFromSharedColor (borderColors.right) resolvedColorWithTraitCollection: traitCollection] };
923931}
924932
925933static CALayerCornerCurve CornerCurveFromBorderCurve (BorderCurve borderCurve)
@@ -1157,7 +1165,8 @@ - (void)invalidateLayer
11571165 _borderLayer = nil ;
11581166
11591167 layer.borderWidth = (CGFloat)borderMetrics.borderWidths .left ;
1160- UIColor *borderColor = RCTUIColorFromSharedColor (borderMetrics.borderColors .left );
1168+ UIColor *borderColor = [RCTUIColorFromSharedColor (borderMetrics.borderColors.left)
1169+ resolvedColorWithTraitCollection: self .traitCollection];
11611170 layer.borderColor = borderColor.CGColor ;
11621171 layer.cornerRadius = (CGFloat)borderMetrics.borderRadii .topLeft .horizontal ;
11631172 layer.cornerCurve = CornerCurveFromBorderCurve (borderMetrics.borderCurves .topLeft );
@@ -1175,7 +1184,8 @@ - (void)invalidateLayer
11751184 layer.borderColor = nil ;
11761185 layer.cornerRadius = 0 ;
11771186
1178- RCTBorderColors borderColors = RCTCreateRCTBorderColorsFromBorderColors (borderMetrics.borderColors );
1187+ RCTBorderColors borderColors =
1188+ RCTCreateRCTBorderColorsFromBorderColors (borderMetrics.borderColors , self.traitCollection );
11791189
11801190 RCTAddContourEffectToLayer (
11811191 _borderLayer,
@@ -1201,11 +1211,13 @@ - (void)invalidateLayer
12011211 layer.bounds , -_props->outlineOffset - _props->outlineWidth , -_props->outlineOffset - _props->outlineWidth );
12021212
12031213 if (areBorderRadiiCircular (borderMetrics.borderRadii ) && borderMetrics.borderRadii .topLeft .horizontal == 0 ) {
1204- UIColor *outlineColor = RCTUIColorFromSharedColor (_props->outlineColor );
1214+ UIColor *outlineColor = [RCTUIColorFromSharedColor (_props->outlineColor)
1215+ resolvedColorWithTraitCollection: self .traitCollection];
12051216 _outlineLayer.borderWidth = _props->outlineWidth ;
12061217 _outlineLayer.borderColor = outlineColor.CGColor ;
12071218 } else {
1208- UIColor *outlineColor = RCTUIColorFromSharedColor (_props->outlineColor );
1219+ UIColor *outlineColor = [RCTUIColorFromSharedColor (_props->outlineColor)
1220+ resolvedColorWithTraitCollection: self .traitCollection];
12091221
12101222 RCTAddContourEffectToLayer (
12111223 _outlineLayer,
0 commit comments