diff --git a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js index 405ab500acc589..8923582c394f74 100644 --- a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +++ b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js @@ -33,6 +33,8 @@ type NativeProps = $ReadOnly<{| selectedIndex?: WithDefault, enabled?: WithDefault, tintColor?: ?ColorValue, + textColor?: ?ColorValue, + backgroundColor?: ?ColorValue, momentary?: WithDefault, // Events diff --git a/React/Views/RCTSegmentedControl.m b/React/Views/RCTSegmentedControl.m index 5df69e71468933..6c1f1b9f47ad2e 100644 --- a/React/Views/RCTSegmentedControl.m +++ b/React/Views/RCTSegmentedControl.m @@ -39,6 +39,27 @@ - (void)setSelectedIndex:(NSInteger)selectedIndex super.selectedSegmentIndex = selectedIndex; } +- (void)setBackgroundColor:(UIColor *)backgroundColor +{ + #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ + __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 + if (@available(iOS 13.0, *)) { + [super setBackgroundColor:backgroundColor]; + } + #endif +} + +- (void)setTextColor:(UIColor *)textColor +{ + #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ + __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 + if (@available(iOS 13.0, *)) { + [self setTitleTextAttributes:@{NSForegroundColorAttributeName: textColor} + forState:UIControlStateNormal]; + } + #endif +} + - (void)setTintColor:(UIColor *)tintColor { [super setTintColor:tintColor]; diff --git a/React/Views/RCTSegmentedControlManager.m b/React/Views/RCTSegmentedControlManager.m index 8b3573ab485ec6..a5e921d3c1e4f1 100644 --- a/React/Views/RCTSegmentedControlManager.m +++ b/React/Views/RCTSegmentedControlManager.m @@ -23,6 +23,8 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(values, NSArray) RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger) RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor) +RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor) +RCT_EXPORT_VIEW_PROPERTY(textColor, UIColor) RCT_EXPORT_VIEW_PROPERTY(momentary, BOOL) RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)