Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
extension CGSize {
enum Aspect {
case portrait, landscape, square
var aspect: Aspect {
switch width / height {
case 1.0:
return .square
case 1.0...:
return .landscape
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