Last active
October 25, 2020 03:09
-
-
Save laevandus/5697b609743a04cdd8263aa232cc4636 to your computer and use it in GitHub Desktop.
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 CGSize { | |
enum Aspect { | |
case portrait, landscape, square | |
} | |
var aspect: Aspect { | |
switch width / height { | |
case 1.0: | |
return .square | |
case 1.0...: | |
return .landscape | |
default: | |
return .portrait | |
} | |
} | |
var aspectRatio: CGFloat { | |
return width / height | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment