Created
April 27, 2020 10:42
-
-
Save mhdhejazi/bbf5c209fa8ff9dc50be2a7c7809d7c4 to your computer and use it in GitHub Desktop.
Change the window scale factor in a Mac Catalyst app with the help of Dynamic (https://github.com/mhdhejazi/Dynamic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidAppear(_ animated: Bool) { | |
view.window?.scaleFactor = 1.0 // Default value is 0.77 | |
} | |
extension UIWindow { | |
var scaleFactor: CGFloat { | |
get { | |
Dynamic.NSApplication.sharedApplication | |
.windows.firstObject.contentView | |
.subviews.firstObject.scaleFactor ?? 1.0 | |
} | |
set { | |
Dynamic.NSApplication.sharedApplication | |
.windows.firstObject.contentView | |
.subviews.firstObject.scaleFactor = newValue | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A safer way for finding the scene view would be: