Skip to content

Instantly share code, notes, and snippets.

@hamada-lemois
Created January 28, 2015 07:10
Show Gist options
  • Select an option

  • Save hamada-lemois/244f1c78f189410cdf2d to your computer and use it in GitHub Desktop.

Select an option

Save hamada-lemois/244f1c78f189410cdf2d to your computer and use it in GitHub Desktop.
SwiftでConstraint
var topConstraint = NSLayoutConstraint(
item: view,
attribute: .Top,
relatedBy: .Equal,
toItem: subView,
attribute: .Top,
multiplier: 1,
constant: 0)
var leadingConstraint = NSLayoutConstraint(
item: view,
attribute: .Leading,
relatedBy: .Equal,
toItem: subView,
attribute: .Leading,
multiplier: 1,
constant: 0)
var trailingConstraint = NSLayoutConstraint(
item: view,
attribute: .Trailing,
relatedBy: .Equal,
toItem: subView,
attribute: .Trailing,
multiplier: 1,
constant: 0)
var bottomConstraint = NSLayoutConstraint(
item: view,
attribute: .Bottom,
relatedBy: .Equal,
toItem: subView,
attribute: .Bottom,
multiplier: 1,
constant: 0)
view.addConstraints([topConstraint, leadingConstraint, trailingConstraint, bottomConstraint])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment