Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages