Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save imWildCat/6c74ee153e1be65c42edbf110757dc50 to your computer and use it in GitHub Desktop.
Save imWildCat/6c74ee153e1be65c42edbf110757dc50 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)
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