From the UIStackView Class Reference
In removeArrangedSubview:
To prevent the view from appearing on screen after calling the stack’s removeArrang
Hacking With Swift provides a pretty good example and explanation, using Web views in this case.
The reason is that you can remove something from a stack view's arranged subview list then re-add it later, without having to recreate it each time – it was hidden, not destroyed. We don't want a memory leak, so we want to remove deleted web views entirely. If you find your memory usage ballooning, you probably forgot this step!
https://www.hackingwithswift.com/read/31/4/removing-views-from-a-uistackview-with-removearrangedsubview