Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Here is an example of using my [EasyLayout](https://gist.github.com/praeclarum/6225853) library. Note the use of <= and >=, these are very difficult to write in old fashioned (frame-based) layout code. Also note the extension method GetMidY() that emulates Center.Y. You can also use GetBaseline() that works for baseline-aware views.
ContentView.ConstrainLayout (() =>
border.Frame.Top == ContentView.Frame.Top &&
border.Frame.Height == 0.5f &&
border.Frame.Left == ContentView.Frame.Left &&
border.Frame.Right == ContentView.Frame.Right &&
nameLabel.Frame.Left == ContentView.Frame.Left + hpad &&
nameLabel.Frame.Right == ContentView.Frame.GetMidX () - 5.5f &&
nameLabel.Frame.Top >= ContentView.Frame.Top + vpad &&
nameLabel.Frame.Bottom <= ContentView.Frame.Bottom - vpad &&
nameLabel.Frame.GetMidY () == ContentView.Frame.GetMidY () &&
gestureView.Frame.Left <= ContentView.Frame.GetMidX () - 22 &&
gestureView.Frame.Right >= scalarLabel.Frame.Right + 22 &&
gestureView.Frame.Width >= 88 &&
gestureView.Frame.Top == ContentView.Frame.Top &&
gestureView.Frame.Bottom == ContentView.Frame.Bottom &&
scalarLabel.Frame.Bottom == ContentView.Frame.Bottom - vpad &&
scalarLabel.Frame.Left == nameLabel.Frame.Right + 11 &&
scalarLabel.Frame.Right <= ContentView.Frame.Right - hpad &&
scalarLabel.Frame.GetMidY () == ContentView.Frame.GetMidY () &&
unitsLabel.Frame.Left == scalarLabel.Frame.Right + 1 &&
unitsLabel.Frame.GetBaseline () == scalarLabel.Frame.GetBaseline ()
);
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.