Non verbose way to create constraints and work with anchors.
This framework provides:
view.topAnchor == superview.topAnchor ~ .high + 10
It also lets you store the constraint after definition.
let constraint = view.topAnchor == superview.topAnchor ~ .high ↑ "CustomIdentifier"
scrollview.edgeAnchor == superview.edgeAnchor
It lets you work with anchor groups similarly than you would work with simple anchors.
scrollview.edgeAnchor == superview.edgeAnchor + 5 ~ .low
let container = view.directionalEdgeAnchor >= superview.directionalEdgeAnchor + 3 ~ .required
container.leading.constant = 10
container.bottom.isActive = true
Autolayout lets you perform normal constraint operations on the whole constraint container.
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 ;)
link |
Stars: 2 |
Last commit: 39 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics