Non verbose way to create constraints and work with anchors.
This framework provides:
It also lets you store the constraint after definition.
view.topAnchor == superview.topAnchor ~ .high + 10
let constraint = view.topAnchor == superview.topAnchor ~ .high ↑ "CustomIdentifier"
It lets you work with anchor groups similarly than you would work with simple anchors.
scrollview.edgeAnchor == superview.edgeAnchor
scrollview.edgeAnchor == superview.edgeAnchor + 5 ~ .low
Autolayout lets you perform normal constraint operations on the whole constraint container.
let container = view.directionalEdgeAnchor >= superview.directionalEdgeAnchor + 3 ~ .required container.leading.constant = 10 container.bottom.isActive = true
container.constant = 10
view.horizontalAnchor == superview.directionalAnchor view.sizeAnchor >= superview.verticalAnchor
This code and tool is under the MIT License. See LICENSE file in this repository.
Any ideas and contributions welcome!
This framework was initially influenced by Anchorage by Raizlabs. Although the syntax is similar, Autolayout provide a completely different internals and generics system to facilitate compile-time checks and group operations (such as activity or constant settings).
In any case, Anchorage is still a great tool that I thoroughly recommend to anyone ;)
|Last commit: 2 weeks ago|