I have one screen. It will display like below
Now When User clicked I have an Account and Password(button) it will display like below
I want to move both views accordingly I added constraints using storyboard.Now need to change constraints from programming..
Select the view you would like to constrain. Then tap the button to the right of the one you have selected and use that menu to define your autolayout constraints. If you want it to work for all devices make sure your storyboard is on the wAny hAny size class setting.
Clicking the Edit button in any of the constraints brings up a popover where you can change the constraint's relationship, constant, priority, or multiplier. To make additional changes, double-click the constraint to select it and open it in the Attribute inspector.
You need to create an IBOutlet of your constraint.
Then you set the constant value of your constraint in code:
labelWidthConstraint.constant = newValue
If you want it animated you can do something like this:
labelWidthConstraint.constant = newValue UIView.animate(withDuration: 0.3, animations: { self.view.layoutIfNeeded() })
self.labelWidthConstraint.constant = newValue; [UIView animateWithDuration:0.3 animations:^{ [self.view layoutIfNeeded]; }];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With