我有一个非常简单的项目,我想在标签上设置右边距的动画,但是当我尝试它时,它会立即完成。NSLayoutConstraint动画立即完成
@IBAction func onDo(sender:UIButton)
{
self.view.setNeedsLayout()
self.testConstraint.constant = 40.0
UIView.animateWithDuration(2.0, animations: {() -> Void in
self.view.setNeedsLayout()
}) { (complete:Bool) -> Void in
}
}
该项目是在这里:
https://www.dropbox.com/s/9a0v0906riunkww/test2222.zip?dl=0
我失去了一些东西明显?
更新#1
看来它与UILabels一个问题而言,标准的UIView,或UIButton的动画罚款....有啥错一个UILabel?
更新#2
如果我设置的UILabel视图内容模式为中心,然后它工作正常,但它看起来并不很流畅......很奇怪。
呼叫更换
self.view.setNeedsLayout()
'layoutIfNeeded()','不setNeedsLayout()' – dan我已经试过,在测试项目,它跳跃太:-( – Chris
这很奇怪,这里有一些想法http://stackoverflow.com/q/17360402/2683201 –