下面的函数只是将视图移动到新的位置。它没有显示动画:约束的快速动画不起作用
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 0.9, animations: {
//self.leadingConst.constant -= 200
self.view.setNeedsLayout()
})
}
'self.view.layoutIfNeeded()'是实际动画发生的时间。 'setNeedsLayout()'只是告诉我需要在下一遍中布局的视图,但实际上并没有这样做。 – PeejWeej