You need to first change the constraint and then animate the update.
self.nameInputConstraint.constant = 8
UIView.animate(withDuration: 0.5) {
self.view.layoutIfNeeded()
}
self.nameInputConstraint.constant = 10
UIView.animate(withDuration: 0.5) {
self.view.layoutIfNeeded()
}
self.nameInputConstraint.constant = 8
UIView.animate(withDuration: 0.5) {
self.view.layoutIfNeeded()
}