diff --git a/packages/react-native/React/Base/RCTUtils.m b/packages/react-native/React/Base/RCTUtils.m index 01bd5cde9fc3df..110472aaee4535 100644 --- a/packages/react-native/React/Base/RCTUtils.m +++ b/packages/react-native/React/Base/RCTUtils.m @@ -302,14 +302,14 @@ static void RCTUnsafeExecuteOnMainQueueOnceSync(dispatch_once_t *onceToken, disp void RCTComputeScreenScale(void) { dispatch_once(&onceTokenScreenScale, ^{ - screenScale = [UIScreen mainScreen].scale; + screenScale = [UITraitCollection currentTraitCollection].displayScale; }); } CGFloat RCTScreenScale(void) { RCTUnsafeExecuteOnMainQueueOnceSync(&onceTokenScreenScale, ^{ - screenScale = [UIScreen mainScreen].scale; + screenScale = [UITraitCollection currentTraitCollection].displayScale; }); return screenScale; diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index bab5f1ee526ec3..9fa696f7a49a72 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -252,7 +252,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & // `shouldRasterize` if (oldViewProps.shouldRasterize != newViewProps.shouldRasterize) { self.layer.shouldRasterize = newViewProps.shouldRasterize; - self.layer.rasterizationScale = newViewProps.shouldRasterize ? [UIScreen mainScreen].scale : 1.0; + self.layer.rasterizationScale = newViewProps.shouldRasterize ? self.traitCollection.displayScale : 1.0; } // `pointerEvents` diff --git a/packages/react-native/React/Views/RCTViewManager.m b/packages/react-native/React/Views/RCTViewManager.m index 5f5c6ce19016a5..66c449d7e81a00 100644 --- a/packages/react-native/React/Views/RCTViewManager.m +++ b/packages/react-native/React/Views/RCTViewManager.m @@ -213,7 +213,7 @@ - (RCTShadowView *)shadowView { view.layer.shouldRasterize = json ? [RCTConvert BOOL:json] : defaultView.layer.shouldRasterize; view.layer.rasterizationScale = - view.layer.shouldRasterize ? [UIScreen mainScreen].scale : defaultView.layer.rasterizationScale; + view.layer.shouldRasterize ? view.traitCollection.displayScale : defaultView.layer.rasterizationScale; } RCT_REMAP_VIEW_PROPERTY(transform, reactTransform, CATransform3D) diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.m b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.m index 2ddf514138d0d1..e46d975ea0b80b 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.m +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/UIImage+Compare.m @@ -42,7 +42,7 @@ - (BOOL)compareWithImage:(UIImage *)image CGImageGetColorSpace(image.CGImage), (CGBitmapInfo)kCGImageAlphaPremultipliedLast); - CGFloat scaleFactor = [UIScreen mainScreen].scale; + CGFloat scaleFactor = [UITraitCollection currentTraitCollection].displayScale; CGContextScaleCTM(referenceImageContext, scaleFactor, scaleFactor); CGContextScaleCTM(imageContext, scaleFactor, scaleFactor);