I have a UIStackView with the config below, when i hide its first subview i want it to shrink in height rather than redistributing the height of the existing cells to fill or leaving white space.
Is there a way to achieve this? as currently it wont change in height despite hiding its contents
let headerStackView = UIStackView()
headerStackView.backgroundColor = .clear
headerStackView.axis = .vertical
headerStackView.alignment = .fill
headerStackView.distribution = .equalSpacing
headerStackView.spacing = 0
headerStackView.isUserInteractionEnabled = true
headerStackView.translatesAutoresizingMaskIntoConstraints = false
Constraints
headerStackView.snp.makeConstraints { (make) -> Void in
make.leading.trailing.bottom.equalToSuperview()
make.top.equalTo(topView.snp.bottom)
}
Hiding of subview (opposite for showing)
UIView.animate(withDuration: 0.35) { [weak self] in
headerStackView.arrangedSubviews.first.isHidden = true
headerStackView.arrangedSubviews.first.alpha = 0
self?.detailsHeaderView.headerStackView.layoutIfNeeded()
}