Skip to content

Instantly share code, notes, and snippets.

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 maximbilan/d3e8de14c50b0f59308b119aae22d89d to your computer and use it in GitHub Desktop.
Save maximbilan/d3e8de14c50b0f59308b119aae22d89d to your computer and use it in GitHub Desktop.
NSLayoutConstraint Multiplier Extension
extension NSLayoutConstraint {
func setMultiplier(multiplier:CGFloat) -> NSLayoutConstraint {
let newConstraint = NSLayoutConstraint(
item: firstItem,
attribute: firstAttribute,
relatedBy: relation,
toItem: secondItem,
attribute: secondAttribute,
multiplier: multiplier,
constant: constant)
newConstraint.priority = priority
newConstraint.shouldBeArchived = self.shouldBeArchived
newConstraint.identifier = self.identifier
newConstraint.active = true
NSLayoutConstraint.deactivateConstraints([self])
NSLayoutConstraint.activateConstraints([newConstraint])
return newConstraint
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment