From the UIStackView Class Reference
In removeArrangedSubview:
To prevent the view from appearing on screen after calling the stack’s removeArrang
I will suggest get arranged subviews then remove it like below code .
for view in self.stackView.arrangedSubviews{ self.stackView.removeArrangedSubview(view) view.removeFromSuperview() }