What I usually do in this situation is the following.
Add two limitations to your scene. One where it is aligned to the left of the button and the "single" label. The second one, where it is aligned to the left of the button and the “second” label (ie Both values will be 0). These restrictions first conflict with each other, and that’s fine.
Add IBOutlets to the view controller for NSLayoutConstraints and assign the two constraints that we created to those << 20>.
Set the restriction priority for your initial condition to 999 (that is, the restriction in the left match with "one" should be 999). Set the priority of the restriction to limit the assignment to 998 (i.e., the restriction on the left alignment between the buttons on the "second" is 998). You will now see that these restrictions will no longer conflict. This is due to the fact that the priority of one restriction overrides another.
You can see where it is heading. Therefore, when you want to animate a button between restrictions, change priorities and animate!
code:
@interface MyViewController () @property (nonatomic, weak) NSLayoutConstraint* constraint0; @property (nonatomic, weak) NSLayoutConstraint* constraint1; @end - (void)someMethodWhereIWantToAnimate { NSInteger temp = constraint0.priority; constraint0.priority = constraint1.priority; constraint1.priority = temp; [UIView animateWithDuration:1.0 animations:^{
source share