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

Fix UI overlay scale factor for readable display on iOS devices #1142

Merged
merged 1 commit into from
Jun 21, 2024
Merged
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
6 changes: 4 additions & 2 deletions apple/ios/DemoViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ -(void) viewDidLoad {

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;
Expand Down
Loading