My code below does exactly what I am looking for the problem is it just does this in a uibtton. I would like to do the same thing with 2 uitextfields and 2 uilabels. So textfield to uilabel to textfield to uilabel. I assume you would just have to change "button in" but I dont know what to change it with. I want the objects spaced 40 between each other just like below.
func setConstraints() {
var yPosition: CGFloat = 0
[undoButton, clearButton, color].forEach { button in
NSLayoutConstraint.activate([
button.trailingAnchor.constraint(equalTo: view.centerXAnchor, constant :25),
button.topAnchor.constraint(equalTo: view.centerYAnchor, constant : yPosition),
button.widthAnchor.constraint(equalToConstant: CGFloat(widthBox)),
button.heightAnchor.constraint(equalToConstant: 20)
])
yPosition += 40
}
}