Reputation: 101
I'm using auto layout to center my primary UIView horizontally and vertically. What I'm trying to do is animate the height from 363 to 182 while the subview which has a height of 182 pushes from its current offset to a y offset of 0.
In slightly less confusing terminology: The goal is to have the subview towards the bottom, slide over the content at the top of the parent view while the parent view changes its height to the height of the subview.
Changing one before the other seems to break it either way. My last resort option is to have a view under the subview, that matches the background color of the controller to hide the fact that the parent view doesn't resize, but I'm using a corner radius so it would be kinda ugly that way.
I somewhat new to this whole auto layout thing so I'm hoping there's a better solution.
Any help is greatly appreciated.
Thanks :)
Upvotes: 1
Views: 1536
Reputation: 385690
Presumably you have a height constraint on the parent and a top constraint on the subview.
parentHeightConstraint.constant = 182
childTopConstraint.constant = 0
UIView.animateWithDuration(0.3) {
parentView.window?.layoutIfNeeded()
}
Upvotes: 2