相关疑难解决方法(0)

UICollectionViewCell - 内容不与单元格的contentView一起制作动画

问题看起来像这样:http: //i.imgur.com/5iaAiGQ.mp4(红色是cell.contentView的颜色)

这是代码:https://github.com/nezhyborets/UICollectionViewContentsAnimationProblem

当前状态: UICollectionViewCell的contentView的内容不会与contentView框架更改一起动画.它立即获得大小没有动画.

执行任务时遇到的其他问题: contentView也没有动画到单元格的帧更改,直到我在UICollectionViewCell子类中执行此操作:

override func awakeFromNib() {
    super.awakeFromNib()

    //Because contentView won't animate along with cell
    contentView.frame = bounds
    contentView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
}
Run Code Online (Sandbox Code Playgroud)

其他说明: 以下是单元格大小动画中涉及的代码

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
    self.selectedIndex = indexPath.row

    collectionView.performBatchUpdates({
        collectionView.reloadData() 
    }, completion: nil)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    let isSelected = self.selectedIndex == indexPath.row
    let someSize : CGFloat = 90 //doesn't matter
    let sizeK …
Run Code Online (Sandbox Code Playgroud)

animation ios uicollectionview uicollectionviewcell

15
推荐指数
2
解决办法
2532
查看次数