A DSL for Auto Layout in Swift
To integrate SwiftLayout into your Xcode project using Carthage, specify it in your Cartfile
:
github "zetasq/SwiftLayout"
Run carthage update
to build the framework and drag the built SwiftLayout.framework
into your Xcode project.
Just as you write equations and inequations in mathmatics, in SwiftLayout you do the same!
let viewA = UIView()
let viewB = UIView()
var savedConstraint: NSLayoutConstraint!
viewA.addSubview(viewB)
viewB.slt.layout {
$0.top == viewA.slt.top + 5
$0.centerX == viewA.slt.centerX
($0.leading >= viewA.slt.leading).priority(.defaultHigh)
savedConstraint = ($0.bottom <= viewA.slt.bottom - 15).constraint
}
SwiftLayout is released under the MIT license. See LICENSE for details.