acani / AutoLayout

Auto Layout helper methods

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AutoLayout

Auto Layout helper methods

Setup: How to add a Git repository to your Xcode project

Usage:

  • Initialize a constraint with optional arguments

    Give view1 a width of 100

    let constraint = NSLayoutConstraint(item: view1, attribute: .Width, constant: 100)

    Make the tops of view1 & view2 equal

    let constraint = NSLayoutConstraint(item: view1, attribute: .Top, item: view2)
  • Create constraints for a subview with insets

    let insets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0)
    let constraints = NSLayoutConstraint.constraintsWithSubview(textField, subview: contentView, insets: insets)
    NSLayoutConstraint.activateConstraints(constraints)

Released under the Unlicense.

About

Auto Layout helper methods


Languages

Language:Swift 100.0%