The below is in a loop which adds views to a superview. Each subview is the remove button and information to the left.....they are sitting in a parent view...
Each subview is constrained to the view above...and the top view is constrained to the top edge of the parent view..all added programatically.
The remove button will delete one at a time
Once I add a secondary top constraint to each view to account for the deleting then I get the following....
var horizontalConstraint1 = NSLayoutConstraint()
var horizontalConstraint2 = NSLayoutConstraint()
var verticalConstraint1 = NSLayoutConstraint()
var verticalConstraintOuter = NSLayoutConstraint()
horizontalConstraint1 = v.leadingAnchor.constraint(equalTo: (v.superview?.leadingAnchor)!,constant:10)
horizontalConstraint2 = v.trailingAnchor.constraint(equalTo: (v.superview?.trailingAnchor)!,constant:-10)
if self.prevView == nil{
verticalConstraint1 = v.topAnchor.constraint(equalTo: (v.superview?.topAnchor)!, constant: 0)
NSLayoutConstraint.activate([horizontalConstraint1,horizontalConstraint2,verticalConstraint1 ])
}else {
if let pv = self.prevView as? UIView {
verticalConstraint1 = v.topAnchor.constraint(equalTo: (pv.bottomAnchor), constant: 10)
verticalConstraintOuter = v.topAnchor.constraint(equalTo: (v.superview?.topAnchor)!,constant:10 )
verticalConstraintOuter.priority = UILayoutPriority(rawValue: 800)
NSLayoutConstraint.activate([horizontalConstraint1,horizontalConstraint2,verticalConstraint1,verticalConstraintOuter])
}
}
self.prevView = v

