Last active
November 3, 2017 16:20
-
-
Save phynet/9eecedf4f3b4d9aab8c245061baee774 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| struct MyConstraint { | |
| static func changeMultiplier(constraint: NSLayoutConstraint, multiplier: CGFloat) -> NSLayoutConstraint { | |
| let newConstraint = NSLayoutConstraint( | |
| item: constraint.firstItem, | |
| attribute: constraint.firstAttribute, | |
| relatedBy: constraint.relation, | |
| toItem: constraint.secondItem, | |
| attribute: constraint.secondAttribute, | |
| multiplier: multiplier, | |
| constant: constraint.constant) | |
| newConstraint.priority = constraint.priority | |
| NSLayoutConstraint.deactivateConstraints([constraint]) | |
| NSLayoutConstraint.activateConstraints([newConstraint]) | |
| return newConstraint | |
| } | |
| } | |
| //Usage, changing multiplier to 1.2: | |
| constraint = MyConstraint.changeMultiplier(constraint, multiplier: 1.2) | |
| //http://stackoverflow.com/questions/19593641/can-i-change-multiplier-property-for-nslayoutconstraint |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment