我正在尝试对视图的底部约束进行动画处理,使其向上滑动。
这就是我正在做的,但它只是立即跳到新的位置,它不会滑动:
UIView.animate(withDuration: 0.4) {
self.pickerBottomConstraint.constant += 300
self.agePicker.setNeedsLayout()
self.agePicker.layoutIfNeeded()
}有人知道如何在iOS14中为约束设置动画吗?
发布于 2020-10-08 04:23:18
你需要
self.pickerBottomConstraint.constant += 300 // this should be outside of animate
UIView.animate(withDuration: 0.4) {
self.view.layoutIfNeeded() // this should be called for at least the direct parent of the animated picker
} https://stackoverflow.com/questions/64251651
复制相似问题