I have a strange problem. I want to change the restriction in certain conditions, but it removeConstraintdoes not work. The restriction is not removed.
Here is the code:
backButton.translatesAutoresizingMaskIntoConstraints = false
view.removeConstraint(constLabelTop)
let constNew = NSLayoutConstraint(item: label, attribute: .CenterY, relatedBy: .Equal, toItem: backButton, attribute: .CenterY,multiplier: 1, constant: 0)
view.addConstraint(constNew)
A constraint constLabelTopis a constraint that sets the top labela few points higher backButton. Why is this not working?
The new constraint collides with the old, but backButtonreceives compression.
I also tried backButton.removeConstraintand did not work.
source
share