From cc2c05ba45c8b3cc516837d86bb8513d7b864c91 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Fri, 21 Jun 2024 01:50:07 -0400 Subject: [PATCH] Fix UI overlay scale factor for readable display on iOS devices (#1142) --- apple/ios/DemoViewController.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apple/ios/DemoViewController.mm b/apple/ios/DemoViewController.mm index c15d303a..8b5e530c 100644 --- a/apple/ios/DemoViewController.mm +++ b/apple/ios/DemoViewController.mm @@ -36,9 +36,11 @@ CALayer* layer; layer = [self.view layer]; // SRS - When creating a Vulkan Metal surface, need the layer backing the view - self.view.contentScaleFactor = UIScreen.mainScreen.nativeScale; + layer.contentsScale = UIScreen.mainScreen.nativeScale; - _mvkExample = new MVKExample(self.view, 1.0f); // SRS - Use 1x scale factor for UIOverlay on iOS + // SRS - Calculate UI overlay scale factor based on backing layer scale factor and device type for readable UIOverlay on iOS devices + auto UIOverlayScale = layer.contentsScale * ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone ? 2.0/3.0 : 1.0 ); + _mvkExample = new MVKExample(self.view, UIOverlayScale); // SRS - Enable AppDelegate to call into DemoViewController for handling app lifecycle events (e.g. termination) auto appDelegate = (AppDelegate *)UIApplication.sharedApplication.delegate;