zetasq / SwiftLayout

A simple DSL written in Swift for Auto Layout.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwiftLayout

A DSL for Auto Layout in Swift

Carthage Compatible

Installation

Carthage

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.

Usage

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
}

License

SwiftLayout is released under the MIT license. See LICENSE for details.

About

A simple DSL written in Swift for Auto Layout.

License:MIT License


Languages

Language:Swift 98.1%Language:Objective-C 1.9%