Open swapnil-sankla opened 8 years ago
The official UIStackView does not behave like that.
"This method removes the provided view from the stack’s arrangedSubviews array. The view’s position and size will no longer be managed by the stack view. However, this method does not remove the provided view from the stack’s subviews array; therefore, the view is still displayed as part of the view hierarchy."
Interesting, at least the animation is still preserved!
[stack removeArrangedSubview:subview];
[subview removeFromSuperview];
// Still animates out nicely!
The current implementation of removing arrangedSubView is not great because even after removing arranged subView the view is still present. Remove arrangedSubView should work as expected.
A bonus would be if we can remove all the arrangedSubViews together. Some thing like -
@objc func removeAllArrangedSubViews() { for arrangedSubView in arrangedSubviews { removeArrangedSubview(arrangedSubView) arrangedSubView.removeFromSuperview() } updateConstraints() }