RE: RE: ConstraintMaker for Autolayout
You are viewing a single comment's thread from:

RE: ConstraintMaker for Autolayout

RE: ConstraintMaker for Autolayout

redView.prepareForNewConstraints { (v) in
            v?.setLeadingSpaceFromSuperView(leadingSpace: 50)
            v?.setTrailingSpaceFromSuperView(trailingSpace: -50)
            v?.setTopSpaceFromSuperView(topSpace: 50)
            v?.pinHeightConstraint(constant: 200)
NSLayoutConstraint.constraintsWithVisualFormat("V:|-50-[v1(200)]", options: [], metrics: nil, v1: "redView")
NSLayoutConstraint.constraintsWithVisualFormat("H:|-50-[v1]-50-|", options: [], metrics: nil, v1: "redView")

Ofcourse it's a matter of choice, but you'll need to import that class everytime, you need to keep up with updates. I'm not sure if it's efficiently work on phone rotations. And by you mean lesser code you'll need to memorize.

  • setLeadingSpaceFromSuperView
  • setTrailingSpaceFromSuperView
  • setTopSpaceFromSuperView
  • pinHeightConstraint
  • centerHorizontallyWithView
  • setVerticalSpaceFrom

And if you start to work with others they'll suffer from it IMO.

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center