Skip to content

Equations, Side Alignments & Percentage-based layouts

Compare
Choose a tag to compare
@s4cha s4cha released this 21 Jan 11:05
· 236 commits to master since this release

Equations Support

addConstraint(item: button,
                      attribute: .centerY,
                      toItem: avatar,
                      attribute: .bottom,
                      constant: -4)

Becomes

button.CenterY == avatar.Bottom - 4

Examples

label.Width == button.Width * 3
label.Height == (button.Width / 7) + 3
button.Left == image.Right - 20

Side Alignments

addConstraint(item: label, attribute: .top, toItem: avatar)

Becomes

alignTops(label, avatar)

Examples

alignTops(label, avatar, square)
alignBottoms(v1, v2, v3, v4)
alignLefts(button, image)
alignRights(v1, v2)

Percentage-Based Layout

addConstraint(item: label, attribute: .top, toItem: superview, attribute: .bottom, constant: 0.05)

Becomes

label.top(5%)

Examples

label.top(5%)
view.size(30%)
view.width(50%)
label.Top == 5 % Top