i'm trying to add a button back into a stackview and i'm not sure how to do it in the code, i only want the button to appear under a circumstance so that's why i'm doing it in code, here's what i have
i'm removing it with
func hideCompareButton() {
UIView.animateWithDuration(0.4, animations: {
self.compareButton.alpha = 0
}) { completed in
if completed == true {
self.compareButton.removeFromSuperview()
}
}
}
and i've got this that would normally work with other views, but i'm not sure how to add a button onto a stackview, at a prefered locations, there's 3 buttons when it's not added, 4 when it is, and id like it to be the 3rd button in from the left
func showCompareButton() {
// bottomStackView.addArrangedSubview(compareButton) ???
bottomStackView.addSubview(compareButton)
let bottomConstraint = compareButton.bottomAnchor.constraintEqualToAnchor(view.bottomAnchor)
let leftConstraint = compareButton.leftAnchor.constraintEqualToAnchor(filterButton.rightAnchor)
let rightConstraint = compareButton.rightAnchor.constraintEqualToAnchor(shareButton.leftAnchor)
let heightConstraint = compareButton.heightAnchor.constraintEqualToConstant(44)
NSLayoutConstraint.activateConstraints([bottomConstraint, leftConstraint, rightConstraint, heightConstraint])
bottomStackView.layoutIfNeeded()
}