moo*_*der 13 xcode ios autolayout swift
我在ViewController中查看了sView.它的高度有约束 - 我为这个约束创建了IBOutlet - sViewHeightConstraint.我想用动画降低sView的高度.
我创造了功能
UIView.animateWithDuration(5.5, animations: {
self.sViewHeightConstraint.constant = 50
})
Run Code Online (Sandbox Code Playgroud)
视野的高度正在改变,但我没有看到任何动画.我做错了什么?
EI *_*2.0 50
使用 layoutIfNeeded()
view.layoutIfNeeded() // force any pending operations to finish
UIView.animateWithDuration(0.2, animations: { () -> Void in
self.sViewHeightConstraint.constant = 50
self.view.layoutIfNeeded()
})
Run Code Online (Sandbox Code Playgroud)
迅捷3
view.layoutIfNeeded()
sViewHeightConstraint.constant = 50
UIView.animate(withDuration: 1.0, animations: {
self.view.layoutIfNeeded()
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17488 次 |
最近记录: |