Created
July 21, 2016 12:51
-
-
Save maximbilan/d3e8de14c50b0f59308b119aae22d89d to your computer and use it in GitHub Desktop.
NSLayoutConstraint Multiplier Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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