Skip to content

Instantly share code, notes, and snippets.

@dr2050
Created February 17, 2015 20:27
Show Gist options
  • Save dr2050/a9c479978fb83f2181a0 to your computer and use it in GitHub Desktop.
Save dr2050/a9c479978fb83f2181a0 to your computer and use it in GitHub Desktop.
Box in Square in Cartography, Autolayout for Swift
let percent = 0.3
layout(red, green) { red, green in
red.center == red.superview!.center
red.size == red.superview!.size
green.center == red.superview!.center
// lower priority
green.width == red.width * percent ~ 100
green.height == red.height * percent ~ 100
green.height == green.width // higher than ~ 100 priority
green.width <= red.width * percent
green.height <= red.height * percent
}
@dr2050
Copy link
Author

dr2050 commented Feb 17, 2015

For some reason, the last two lines can be any priority and they work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment