Reputation: 25974
I have used only NSConstraints in Interface Builder to setup a view. Now I have a StackView that I want to animate out. This causes all the Layout to be misplaced.
I have also tried to set translatesAutoresizingMaskIntoConstraints
also tried the following:
self.numbers_Top_Constraint.constant = self.topscreen.frame.size.height
self.topscreen.setNeedsUpdateConstraints()
UIView.animate(withDuration: 0.5, animations: {
self.topscreen.layoutIfNeeded()
}
Do you know how to do this?
Upvotes: 0
Views: 45
Reputation: 374
Use constraints instead of changing frames. Set a top margin constraint to stack view and then change it before the animation and call self.view.layoutIfNeeded(). Something like this -
self.numbersStackViewTopMarginConstriant.constant = self.view.frame.size.height
UIView.animate(withDuration: 0.5, animations: {
self.view.layoutIfNeeded()
}) { (Bool) in
Upvotes: 1