This is the setup:
_vAbout
)_ctrBottomAboutView
)I am using this code to animate:
_ctrBottomAboutView.constant = -100;
[UIView animateWithDuration:0.5 animations:^{
[_vAbout layoutIfNeeded];
}
My problem is: whenever the view has any subviews in it, the animation doesn't work. However, if the view has no children, the animation works correctly.
Do you have any idea of a solution? I have tried everything: adding and removing constraints instead of modificating the constant value, adding constraints to the subviews on Interface Builder...
After some experiments starting from the ground with an empty project, this is what I've found:
Given A the view we want to animate and B its superview
layoutIfNeeded
message is the view that owns the constraint. NSLayoutAttributeWidth
and NSLayoutAttributeHeight
the owner of the constraint is actually A, but in all the other cases, the view that owns the constraint is BHOWEVER
[A layoutIfNeeded]
at any time on our code and it will workviewDidLoad
we can call [A layoutIfNeeded]
and it will workIf 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