I am trying to create an Expandable View using stack view, very easily so when the user clicks on the first arrangedSubview of the StackView the second one's isHidden property is set to false and hence it animates.
The functionality works, but the animation is way off. Every time the isHidden property is set to false, the arranged subview animates not from below the first arrangedSubview, but from the top of the screen instead.
Any ideas on how to fix that? I am using this simple piece of code, as described in Apple's documentation for UIStackView:
UIView.animate(withDuration: animationDuration) {
let bodyView = self.stackView.arrangedSubviews[1]
bodyView.isHidden = !self.isExpanded
self.expandArrowImageView.transform = CGAffineTransform(rotationAngle: angle)
}