hjo*_*uhi 1 ios uicollectionview swift
我试图为集合视图设置高度变化的动画,但我无法弄清楚如何让动画工作.高度正确变化,但它立即发生,而不是动画.
@IBOutlet weak var collectionViewHeight: NSLayoutConstraint!
UIView.animateWithDuration(0.3, delay: 0, options: .CurveEaseOut, animations: {
self.collectionViewHeight.constant = 0
}
Run Code Online (Sandbox Code Playgroud)
我试图寻找解决方案,但找不到任何具体的情况.layoutIfNeeded()
此处也尝试过建议,但它没有帮助:使用Swift动画视图高度
任何帮助非常感谢!
您应该更新动画块之外的约束常量:
self.collectionViewHeight.constant = 0
UIView.animateWithDuration(0.3, delay: 0, options: .CurveEaseOut,
animations: view.layoutIfNeeded, completion: nil)
Run Code Online (Sandbox Code Playgroud)
(view
是有问题的集合视图的超级视图.)
归档时间: |
|
查看次数: |
1438 次 |
最近记录: |