【问题标题】:Animating the UICollectionView Footer height动画 UICollectionView 页脚高度
【发布时间】:2018-04-30 20:41:31
【问题描述】:

我目前正在更改 UICollectionViewDelegateFlowLayout 的页脚高度:

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {

     if shouldDisplay(){
                return CGSize(width: UIScreen.main.bounds.width, height: 100)
     }else{
                return CGSize(width: UIScreen.main.bounds.width, height: 0)
     }
}

但这并不能提供最佳的用户体验。我想为高度设置动画并提供平滑(不)外观。

很遗憾,我没有找到这方面的任何资源。

【问题讨论】:

  • 使用 UIView.animate() 为视图设置动画
  • 可以,但不是 uicollectionview 组件
  • 那么你应该为约束设置动画。
  • 具体:在某处设置约束,然后使用UIView.animate 块,停用旧约束并激活新约束。
  • 大家好。谢谢你的帮助。不幸的是,这对我不起作用:(

标签: ios swift collectionview


【解决方案1】:

您应该继承 UICollectionViewFlowLayout 并实现 initialLayoutAttributesForAppearingSupplementaryElementfinalLayoutAttributesForDisappearingSupplementaryElement 函数。

您可以获取更多关于自定义布局的信息here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-04
    • 1970-01-01
    • 2013-12-14
    • 2019-10-12
    • 1970-01-01
    • 2020-07-09
    相关资源
    最近更新 更多