Skip to content

Instantly share code, notes, and snippets.

@shaps80
Last active June 21, 2017 09:01
Show Gist options
  • Select an option

  • Save shaps80/aab4548a408a887b6b65b339789e2e15 to your computer and use it in GitHub Desktop.

Select an option

Save shaps80/aab4548a408a887b6b65b339789e2e15 to your computer and use it in GitHub Desktop.
Returns a reversible rect, great for producing marquee selection rectangles.
extension CGRect {
public static func reversible(from: CGPoint, to: CGPoint) -> CGRect {
let size = CGSize(width: to.x - from.x, height: to.y - from.y)
return CGRect(origin: from, size: size).standardized
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment