Skip to content

Instantly share code, notes, and snippets.

Embed
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
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
You can’t perform that action at this time.