Update the constant property of a constraint programmatically in Swift?

扶醉桌前 提交于 2019-11-28 21:05:00
duan

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.animateWithDuration(1, animations: {
    self.sampleConstraint.constant = 20
    self.view.layoutIfNeeded()
})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!