constrain
Example
To run the example project, clone the repo, and run Example project only used for testing so farpod install
from the Example directory first.
Requirements
Installation
constrain is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'constrain'
Usage
This library lets you quickly and efficiently set up a number of constraints using intuitive chaining syntax. For example:
let containerView = UIView()
let newView = UIView()
let centeredView = UIView()
containerView.constainSubview(newView).fillSafely()
centeredView.constrainIn(containerView).center()
Notes:
- All constraints are enabled by default
- Adding subviews is handled by
constrainSubview()
,constrainIn()
,constrainSibling()
,constrainSiblingToTrailing()
, orconstrainSiblingToBottom()
. If you need to add more constraints at a later time, just callconstrain
subsequently to avoid redoing it, although there's no harm in it. translatesAutoresizingMaskIntoConstraints
is always set to false- Most methods can also be called with View Controllers, but only the
constrainChild()
method handles parent/child UIViewController relationships. Callremove()
to undo it.
Author
anconaesselmann, [email protected]
License
constrain is available under the MIT license. See the LICENSE file for more info.