我正在尝试使用更新 aUIView
的位置animateWithDuration
。当动画开始发生时,UIView
开始更新,但随后完成使其跳转到正确的位置。这告诉我UIView
' 框架的设置没有正确设置,但我不明白为什么。这是代码:
func showInfoView() {
infoView.hidden = false
let newPosition = self.view.frame.height - (self.infoView.frame.height + 260)
UIView.animateWithDuration(2.0, animations: {
// Set the view to have the new y position
self.infoView.frame.origin.y = newPosition
}, completion: { finished in
// Remove previous constraint
if (self.hintConstraint != nil) {
self.view.removeConstraint(self.hintConstraint)
}
// Create the new constraint
self.hintConstraint = NSLayoutConstraint(item: self.infoView, attribute: .Top, relatedBy: .Equal, toItem: self.view, attribute: .Top, multiplier: 1, constant: newPosition)
self.view.addConstraint(self.hintConstraint)
})
}
谁能帮我理解为什么 y 位置没有在代码中正确设置?