constrain 1.0.3

constrain 1.0.3

Maintained by Eric Groom, Axel Ancona Esselmann, Greg.



constrain 1.0.3

  • By
  • anconaesselmann

constrain

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first. Example project only used for testing so far

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(), or constrainSiblingToBottom(). If you need to add more constraints at a later time, just call constrain 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. Call remove() to undo it.

Author

anconaesselmann, [email protected]

License

constrain is available under the MIT license. See the LICENSE file for more info.