We can change constant property of NSLayoutConstraint, and than use UIView animation block to make the change animated.
myLayoutConstraint.constant = 50;
[UIView animateWithDuration: .3 animations:^{
[view layoutIfNeeded];
}];
However, the subviews of the view, which has layout constraints as their super view, will be animated! They will animate from original zero frame to the target frame of autolayout. How to solve this problem?
This suggests that you have pending layout operations. Call layoutIfNeeded
once before
myLayoutConstraint.constant = 50;
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