【发布时间】:2018-02-10 01:23:51
【问题描述】:
下面的函数只是将视图移动到一个新的地方。它没有显示动画:
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()只是告诉我在下一次传递中需要布局的视图,但实际上并没有这样做。