I'm on a project that is using masonry autolayout, and I'm having some issues with the animation, so the thing I have to do is to have a drawer that will appear from the top of the screen and will appear with an animation, so the content of the container view(it can be 1 view or multiple views) is been added using views with masonry, the issue that I have is that when I debug the views, the frame that I got is always Frame(0 0; 0 0) y since I need to apply animations I need the frame to capture the height of the container view, is there a way to have the correct frame or is it an specific way to work with animations and autolayout?
Try to capture the height of frame in viewDidLayoutSubviews
for UIViewController
or layoutSubviews
for UIView
.
To apply animation for AutoLayout
, you have to reset the constraint like this:
// tell constraints they need updating
[self setNeedsUpdateConstraints];
// update constraints now so we can animate the change
[self updateConstraintsIfNeeded];
[UIView animateWithDuration:0.4 animations:^{
[self layoutIfNeeded];
}];
and update or remake the constraints in updateConstraints
.