In order to declare an animation, you cannot re-define the constraint and call updateConstraints
. You are supposed to change the constant
of your constraint and follow the format below:
self.view.layoutIfNeeded()
UIView.animate(withDuration: 1) {
self.sampleConstraint.constant = 20
self.view.layoutIfNeeded()
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…