---
title: "Better interaction between viewWillTransitionToSize and CGSize"
slug: better-interaction-between-viewwilltransitiontosize-and-cgsize
section: tech
date: 2016-03-31T18:30:00.000Z
canonical: https://roland.leth.ro/blog/tech/better-interaction-between-viewwilltransitiontosize-and-cgsize
---

Instead of checking if `size.width > size.height`, we can have three handy `CGSize` `extensions`:

```swift
extension CGSize {
  var isCompact: Bool { return height > width + delta }
  var isWide: Bool { return width > height + delta }
  var isSquare: Bool { return abs(width - height) < delta } 
}
```

For usage within `viewWillTransition(to:with:)` I don't think the `delta` will be really needed, but if we want to use these properties for our own custom views, it might come in handy. Modify its value to fit your own needs, of course.