ram*_*rio 6 core-animation constraints swift
是否可以通过更改约束来制作UIView动画?
基本上,我想myv使用:UIView.animateWithDuration(1.5) {}通过更改旧约束来设置具有x,y,高度和宽度约束的动画(UIView).
Wye*_*tro 22
是的,这是可能的.你可以这样做:
func AnimateHeight() {
UIView.animateWithDuration(1.5, animations: {
self.heightCons.constant = 250 // Some value
self.view.layoutIfNeeded()
})
}
Run Code Online (Sandbox Code Playgroud)
在哪里self.heightCons是IBOutlet高度约束UIView.
如果您不使用故事板,则可以查看如何以编程方式创建布局约束.