Created
June 15, 2018 10:47
-
-
Save watanabetoshinori/dc33724632a68bd7219fb58ed5319c2c to your computer and use it in GitHub Desktop.
Scaling the contents on UIWindow.
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
extension UIWindow { | |
var scale: CGFloat { | |
get { | |
return sqrt(transform.a * transform.a + transform.c * transform.c) | |
} | |
set { | |
if newValue == 1.0 { | |
transform = CGAffineTransform.identity | |
} else { | |
transform = CGAffineTransform.identity.scaledBy(x: newValue / 1.0, y: newValue / 1.0) | |
} | |
frame = UIScreen.main.bounds | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment