diff --git a/React/Base/RCTUIKit.h b/React/Base/RCTUIKit.h index 69a2845c326570..ce3208eb32b44e 100644 --- a/React/Base/RCTUIKit.h +++ b/React/Base/RCTUIKit.h @@ -479,3 +479,12 @@ NS_INLINE CGRect CGRectValue(NSValue *value) @interface RCTUISlider : NSSlider @end #endif // ]TODO(macOS GH#774) + +// RCTUISwitch + +#if !TARGET_OS_OSX // [TODO(macOS GH#774) +#define RCTUISwitch UISwitch +#else +@interface RCTUISwitch : NSSwitch +@end +#endif // ]TODO(macOS GH#774) diff --git a/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm b/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm index 844b60c120efb8..97c222a82ac6e0 100644 --- a/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm @@ -22,7 +22,7 @@ @interface RCTSwitchComponentView () @end @implementation RCTSwitchComponentView { - UISwitch *_switchView; + RCTUISwitch *_switchView; // TODO(macOS GH#774) BOOL _isInitialValueSet; } @@ -32,7 +32,7 @@ - (instancetype)initWithFrame:(CGRect)frame static const auto defaultProps = std::make_shared(); _props = defaultProps; - _switchView = [[UISwitch alloc] initWithFrame:self.bounds]; + _switchView = [[RCTUISwitch alloc] initWithFrame:self.bounds]; // TODO(macOS GH#774) [_switchView addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged]; @@ -90,7 +90,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & [super updateProps:props oldProps:oldProps]; } -- (void)onChange:(UISwitch *)sender +- (void)onChange:(RCTUISwitch *)sender // TODO(macOS GH#774) { const auto &props = *std::static_pointer_cast(_props); if (props.value == sender.on) {