Skip to content

Instantly share code, notes, and snippets.

@drosenstark
Created February 17, 2015 20:27
Show Gist options
  • Save drosenstark/a9c479978fb83f2181a0 to your computer and use it in GitHub Desktop.
Save drosenstark/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
}
@drosenstark
Copy link
Author

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