Skip to content

Instantly share code, notes, and snippets.

@susieyy
Created January 14, 2017 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susieyy/eab51991cfe73eff6e2119c472bab901 to your computer and use it in GitHub Desktop.
Save susieyy/eab51991cfe73eff6e2119c472bab901 to your computer and use it in GitHub Desktop.
#swtws
parentView.addSubView(childView)
childView.setTranslatesAutoresizingMaskIntoConstraints(false)
parentView.addConstraint(NSLayoutConstraint(item: childView, attribute: .Top, relatedBy: .Equal, toItem: parentView, attribute: .Top, multiplier: 1.0, constant: 0))
parentView.addConstraint(NSLayoutConstraint(item: childView, attribute: .Right, relatedBy: .Equal, toItem: parentView, attribute: .Right, multiplier: 1.0, constant: 0))
parentView.addConstraint(NSLayoutConstraint(item: childView, attribute: .Bottom, relatedBy: .Equal, toItem: parentView, attribute: .Bottom, multiplier: 1.0, constant: 0))
parentView.addConstraint(NSLayoutConstraint(item: childView, attribute: .Left, relatedBy: .Equal, toItem: parentView, attribute: .Left, multiplier: 1.0, constant: 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment