0
votes

I am trying to move a UIView up and off the screen by its height in ios. Below is my code for doing this. What I am finding is that the UIView does indeed move up and off the screen but instead of moving slowly as intended it continues to move off instantaneously without animation. Please can someone advise?

 UIView.animate(withDuration: 300, animations: {
                    let heightOfViewContainingProgrBar = self.viewContainingProgressBar.frame.height
                    self.viewContainingProgressBar.topAnchor.constraint(equalTo: self.view.topAnchor, constant: -heightOfViewContainingProgrBar).isActive = true
                })
2

2 Answers

0
votes

You need to put a call to layoutIfNeeded (for the view or one of it's superviews) inside the animation block.

0
votes

Add

self.view.layoutIfNeeded()

inside animation block