Installation
For now you're able to clone repo in your project or download ZIP folder manually.
git clone https://github.com/votehserxam/AutoLayout.git
After cloning don't forget to add
AutoLayoutfolder in Project Navigator in Xcode.
Usage
All in one
Setup constraints in one place by adding all layout anchors that you need.
thisView.constraints(
    top: thatView.safeArea.top,
    left: thatView.left(20),
    right: thatView.right(20),
    height: .equalToConstant(180)
)
All layout anchors properties are available in shorten form:
topleftbottomrightcenterXcenterYfirstBaselinelastBaselinewidthheight
Notice that
left and rightactually meanleading and trailing, so no need to keep in mind RTL anymore, it just works. Also don't need to add minus tobottomandrightoffsets.
Width and height constraints are defined in the same old ways like .equalToConstant(100) or .equalTo(someView.width), but with more options and combinations.
How to fit one view in another?
If you need to fit one view into another, there is a solution...
// Matching one view with another and making offset from edges.
thisView.match(
    view: thatView,
    offset: .init(
        top: 40,
        bottom: 40
    )
)
// Just matching superview.
thisView.matchSuperview()
How to center views?
Just specify the view with size to center another one in.
// Also you can define offset from center.
thisView.center(
    in: thatView,
    width: .equalTo(thatView.width),
    height: .equalToConstant(120),
    yOffset: 12
)
// Also possible to center in superview.
thisView.centerInSuperview()
Notice that if you don't specify
widthorheightvalues incenterInSuperview(), it will be taken as a superview's size values.