You are viewing a single comment's thread from:

RE: ConstraintMaker for Autolayout

in #utopian-io6 years ago
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.

Sort:  

You just have to drag the class into the project and no need to import the class everytime as swift classes are globally available throughout the project, In swift, you only import module eg. UIKit. This class also has full support for rotation as well. Hope it helps.

Coin Marketplace

STEEM 0.19
TRX 0.17
JST 0.031
BTC 81728.21
ETH 3198.83
USDT 1.00
SBD 2.82