Skip to content

Commit 505d6fe

Browse files
dskuzadskuza
andcommitted
Use trait collection for display scale over window scene
Under certain circumstances, e.g "off-screen rendering" (i.e a Rive view not added to a view hierarchy), there is no window scene available, but there are still trait collections available. When using window scene, Rive would determine it is unable to draw because there is no window scene. However, using the trait collection allows Rive to continue drawing despite not being added to a view hierarchy. This allows manual calls to `draw` to continue when the view is _not_ added to a view hierarchy. Diffs= 13939097af Use trait collection for display scale over window scene (#8472) Co-authored-by: David Skuza <[email protected]>
1 parent 2c0ac3c commit 505d6fe

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

.rive_head

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1d5a58004181e12fddef56e9c2a56a8d14fa451a
1+
13939097af12ef2fa9dbd07835eed8be99f1ff08

Source/Renderer/rive_renderer_view.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ - (void)drawInRect:(CGRect)rect
198198
{
199199
CGFloat scale = -1;
200200
#if TARGET_OS_IPHONE
201-
UIWindowScene* scene = [self.window windowScene];
202-
if (scene != nil)
201+
CGFloat displayScale = self.traitCollection.displayScale;
202+
if (displayScale > 0)
203203
{
204-
scale = scene.screen.scale;
204+
scale = displayScale;
205205
}
206206
#else
207207
NSWindow* window = self.window;

0 commit comments

Comments
 (0)