Last active
June 16, 2018 12:26
-
-
Save praeclarum/8185036 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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