Skip to content

Instantly share code, notes, and snippets.

@leilee
Created September 22, 2016 10:34
Show Gist options
  • Save leilee/a3c157b125916e0205405a0b543f090a to your computer and use it in GitHub Desktop.
Save leilee/a3c157b125916e0205405a0b543f090a to your computer and use it in GitHub Desktop.
change multiplier property for NSLayoutConstraint
import UIKit
public extension NSLayoutConstraint {
func changeMultiplier(multiplier: CGFloat) -> NSLayoutConstraint {
let newConstraint = NSLayoutConstraint(
item: firstItem,
attribute: firstAttribute,
relatedBy: relation,
toItem: secondItem,
attribute: secondAttribute,
multiplier: multiplier,
constant: constant)
newConstraint.priority = priority
NSLayoutConstraint.deactivateConstraints([self])
NSLayoutConstraint.activateConstraints([newConstraint])
return newConstraint
}
}
@gauravr-dev
Copy link

Unfortunately, it is not working in tableview cell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment