I was setting the constraints of a button using a storyboard. I saw an option, \"Identifier\" in the constraint\'s properties.
For resizing a set of buttons within a common view container this works. Each subview/button must use a common identifier (e.g. "height").
@IBAction func btnPressed(_ sender: UIButton) {
for button in self.btnView.subviews{
for constraint in button.constraints{
if constraint.identifier == "height"{
constraint.constant = constraint.constant == 0 ? 30:0
}
}
}
UIView.animate(withDuration: 0.3) { () -> Void in
self.view.layoutIfNeeded()
}
}