TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Rob Broadwell LTD.
To run the example project, clone the repo, and run pod install
from the Example directory first.
layoutpod is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "layoutpod"
The library is an extension on UIView, and adds the following methods:
view.constrainLeftRight(subview)
view.constrainTopBottom(subview)
view.constrainAllSides(subview)
view.constrainCenter(subview)
To fill the Superview with a Subview, it’s just one line:
view.constrainAllSides(subview)
… instead of four:
view.addConstraint(subview.leftAnchor.constraint(equalTo: view.leftAnchor))
view.addConstraint(subview.rightAnchor.constraint(equalTo: view.rightAnchor))
view.addConstraint(subview.topAnchor.constraint(equalTo: view.topAnchor))
view.addConstraint(subview.bottomAnchor.constraint(equalTo: view.bottomAnchor))
You can also pass a ‘padding’ constant to the constraint methods:
view.constrainLeftRight(subview, 20.0)
view.constrainTopBottom(subview, 20.0)
view.constrainAllSides(subview, 20.0)
Rob Broadwell, [email protected]
layoutpod is available under the MIT license. See the LICENSE file for more info.