Skip to content

Instantly share code, notes, and snippets.

@terrybu
Created November 16, 2015 18:18
Show Gist options
  • Save terrybu/a32c2332178873bc92a0 to your computer and use it in GitHub Desktop.
Save terrybu/a32c2332178873bc92a0 to your computer and use it in GitHub Desktop.
autolayout in code in swift
self.canvasView!.addSubview(label)
let widthConstraint = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.LessThanOrEqual, toItem: self.view, attribute: NSLayoutAttribute.Width, multiplier: 1, constant: -40)
self.view.addConstraint(widthConstraint)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment