Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.73-stable] Fix transform prop on View component #2103

Merged
merged 4 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/react-native/React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,14 @@ - (void)displayLayer:(CALayer *)layer
[self updateClippingForLayer:layer];
}

#if TARGET_OS_OSX // [macOS
- (void)updateReactTransformInternal:(CATransform3D)transform
{
[self setTransform3D:transform];
[self setNeedsDisplay];
}
#endif // macOS]

static BOOL RCTLayerHasShadow(CALayer *layer)
{
return layer.shadowOpacity * CGColorGetAlpha(layer.shadowColor) > 0;
Expand Down
8 changes: 8 additions & 0 deletions packages/react-native/React/Views/UIView+React.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@
*/
- (void)reactSetFrame:(CGRect)frame;


#if TARGET_OS_OSX // [macOS
/**
* Used by macOS to propagate transform changes internally.
*/
- (void)updateReactTransformInternal:(CATransform3D)transform;
#endif // macOS]

/**
* This method finds and returns the containing view controller for the view.
*/
Expand Down
11 changes: 11 additions & 0 deletions packages/react-native/React/Views/UIView+React.m
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,21 @@ static void updateTransform(RCTPlatformView *view) // [macOS]
transform = view.reactTransform;
}

#if !TARGET_OS_OSX // [macOS]
view.layer.transform = transform;
// Enable edge antialiasing in rotation, skew, or perspective transforms
view.layer.allowsEdgeAntialiasing = transform.m12 != 0.0f || transform.m21 != 0.0f || transform.m34 != 0.0f;
#else // [macOS
[view updateReactTransformInternal:transform];
#endif // macOS]
}

#if TARGET_OS_OSX // [macOS
- (void)updateReactTransformInternal:(CATransform3D)transform
{
// Do nothing, this will get overridden by RCTView and other subclasses as needed.
}
#endif // macOS]

- (UIViewController *)reactViewController
{
Expand Down