Skip to content

Instantly share code, notes, and snippets.

@laevandus
Last active October 25, 2020 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/5697b609743a04cdd8263aa232cc4636 to your computer and use it in GitHub Desktop.
Save laevandus/5697b609743a04cdd8263aa232cc4636 to your computer and use it in GitHub Desktop.
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