I run the below code on a button press, however the bottom constraint does not seem to be obeyed. The subview (bandCardView) overflows the bottom of the parent view (formVw). How can I make these constraints obeyed?
@objc private func cardBtnTouch(){
self.bandAccountView?.bankBtn.setSelected(selected: false)
self.bandAccountView?.cardBtn.setSelected(selected: true)
self.bandAccountView?.selectLbl.isHidden = true
for subview in self.bandAccountView!.formVw.subviews{
subview.removeFromSuperview()
}
self.bandAccountView!.formVw.addSubview(bandCardView!)
self.bandAccountView!.formVw.addConstraint(NSLayoutConstraint(item: self.bandAccountView!.formVw, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: bandCardView!, attribute: NSLayoutAttribute.top, multiplier: 1.0, constant: 0.0))
self.bandAccountView!.formVw.addConstraint(NSLayoutConstraint(item: bandCardView!, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self.bandAccountView!.formVw, attribute: NSLayoutAttribute.bottom, multiplier: 1.0, constant: 0.0))
self.bandAccountView!.formVw.addConstraint(NSLayoutConstraint(item: bandCardView!, attribute: NSLayoutAttribute.leading, relatedBy: NSLayoutRelation.equal, toItem: self.bandAccountView!.formVw, attribute: NSLayoutAttribute.leading, multiplier: 1.0, constant: 0.0))
self.bandAccountView!.formVw.addConstraint(NSLayoutConstraint(item: self.bandAccountView!.formVw, attribute: NSLayoutAttribute.trailing, relatedBy: NSLayoutRelation.equal, toItem: bandCardView!, attribute: NSLayoutAttribute.trailing, multiplier: 1.0, constant: 0.0))
}