Created
February 20, 2016 16:41
-
-
Save xakpc/e709059261133b77d17c to your computer and use it in GitHub Desktop.
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
#region Process auto layout | |
View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); | |
var btnPadding = 61; | |
var tblPadding = 100; | |
var btnWidth = 100; | |
var btnHeight = 50; | |
// constraints | |
View.AddConstraints ( | |
table.AtTopOf(View, tblPadding), | |
table.AtRightOf(View, tblPadding), | |
table.AtBottomOf(View, tblPadding), | |
table.AtLeftOf(View, tblPadding), | |
buttonTop.AtTopOf(View, btnPadding), | |
buttonTop.WithSameCenterX(table), | |
buttonTop.Width().EqualTo(btnWidth), | |
buttonTop.Height().EqualTo(btnHeight), | |
buttonRight.AtRightOf(View, btnPadding), | |
buttonRight.WithSameCenterY(table), | |
buttonRight.Width().EqualTo(btnHeight), | |
buttonRight.Height().EqualTo(btnWidth), | |
buttonBottom.AtBottomOf(View, btnPadding), | |
buttonBottom.WithSameCenterX(table), | |
buttonBottom.Width().EqualTo(btnWidth), | |
buttonBottom.Height().EqualTo(btnHeight), | |
buttonLeft.AtLeftOf(View, btnPadding), | |
buttonLeft.WithSameCenterY(table), | |
buttonLeft.Width().EqualTo(btnHeight), | |
buttonLeft.Height().EqualTo(btnWidth) | |
); | |
#endregion |
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
View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); | |
var rowSet = new RowSetTemplate() | |
{ | |
TopMargin = 10f, | |
BottomMargin = 20f, | |
VInterspacing = 10f | |
}; | |
var equalWeightRowTemplate = new RowTemplate() | |
{ | |
HInterspacing = 12f, | |
LeftMargin = 6f, | |
RightMargin = 24f | |
}; | |
var addressRowTemplate = new RowTemplate() | |
{ | |
HInterspacing = 12f, | |
LeftMargin = 6f, | |
RightMargin = 24f | |
}; | |
addressRowTemplate.ColumnWeight(0, 0.3f); | |
var townAndZipRowTemplate = new RowTemplate() | |
{ | |
HInterspacing = 12f, | |
LeftMargin = 6f, | |
RightMargin = 24f | |
}; | |
townAndZipRowTemplate.ColumnWidth(1, 120f); | |
View.AddConstraints( | |
rowSet.Generate(View, | |
new Row(equalWeightRowTemplate, _forceTheWidthView), | |
new Row(equalWeightRowTemplate, fNameLabel, sNameLabel), | |
new Row(equalWeightRowTemplate, fNameField, sNameField), | |
new Row(addressRowTemplate, numberLabel, streetLabel), | |
new Row(addressRowTemplate, numberField, streetField), | |
new Row(townAndZipRowTemplate, townLabel, zipLabel), | |
new Row(townAndZipRowTemplate, townField, zipField), | |
new Row(equalWeightRowTemplate, _debugLabel) | |
)); | |
View.AddConstraints(_forceTheWidthView.Width().EqualTo().WidthOf(View).Minus(30f)); |
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
View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); | |
var hMargin = 10; | |
var vMargin = 10; | |
View.AddConstraints( | |
fNameLabel.AtTopOf(View, vMargin + 62), | |
fNameLabel.AtLeftOf(View, hMargin), | |
fNameLabel.ToLeftOf(sNameLabel, hMargin), | |
sNameLabel.WithSameTop(fNameLabel), | |
sNameLabel.AtRightOf(View, hMargin), | |
sNameLabel.WithSameWidth(fNameLabel), | |
fNameField.WithSameWidth(fNameLabel), | |
fNameField.WithSameLeft(fNameLabel), | |
fNameField.Below(fNameLabel, vMargin), | |
sNameField.WithSameLeft(sNameLabel), | |
sNameField.WithSameWidth(sNameLabel), | |
sNameField.WithSameTop(fNameField), | |
numberLabel.WithSameLeft(fNameLabel), | |
numberLabel.ToLeftOf(streetLabel, hMargin), | |
numberLabel.Below(fNameField, vMargin), | |
numberLabel.WithRelativeWidth(streetLabel, 0.3f), | |
streetLabel.WithSameTop(numberLabel), | |
streetLabel.AtRightOf(View, hMargin), | |
numberField.WithSameLeft(numberLabel), | |
numberField.WithSameWidth(numberLabel), | |
numberField.Below(numberLabel, vMargin), | |
streetField.WithSameLeft(streetLabel), | |
streetField.WithSameWidth(streetLabel), | |
streetField.WithSameTop(numberField), | |
townLabel.WithSameLeft(fNameLabel), | |
townLabel.WithSameRight(streetLabel), | |
townLabel.Below(numberField, vMargin), | |
townField.WithSameLeft(townLabel), | |
townField.WithSameWidth(townLabel), | |
townField.Below(townLabel, vMargin), | |
zipLabel.WithSameLeft(fNameLabel), | |
zipLabel.WithSameWidth(townLabel), | |
zipLabel.Below(townField, vMargin), | |
zipField.WithSameLeft(townLabel), | |
zipField.WithSameWidth(zipLabel), | |
zipField.Below(zipLabel, vMargin), | |
debug.WithSameLeft(townLabel), | |
debug.WithSameWidth(zipLabel), | |
debug.AtBottomOf(View, vMargin) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source
https://www.evernote.com/shard/s147/sh/cb15fbce-6975-4bc5-9366-7bcb3dfcf8e3/69acf044ff8197d6