2015-04-30 61 views
0

我正在尝试为第一个单元格的高度设置动画,其余部分要向上或向下滚动。细胞内与.ScaleAspectFill如何使用持续时间动画单个UICollectionView单元格

的形象图我能做到这如果过渡并利用invalidateLayout()和sizeForItemAtIndexPath互动,但我无法弄清楚如何动画结束状态

这里的我在做什么:

let cell = collectionView!.cellForItemAtIndexPath(NSIndexPath(forItem: 0, inSection: 0)) as! HomeFeedCell 
var size:CGSize = getNewSize(cell) 

UIView.transitionWithView(collectionView!, duration: duration, options: .CurveEaseOut | .LayoutSubviews, animations: { 
       cell.frame.size.height = size.height 
      }, completion: nil) 

这使动画第一个单元格,但不移动其余的单元格。我试过的invalidateLayout()或重新加载动画块内可见细胞,但它给了奇怪的结果

回答

0

所以如果有人被套牢相同的答案是还调用集合视图的performBatchUpdates与无更新:块

let cell = collectionView!.cellForItemAtIndexPath(NSIndexPath(forItem: 0, inSection: 0)) as! HomeFeedCell 
var size:CGSize = getNewSize(cell) 

UIView.transitionWithView(collectionView!, duration: duration, options: .CurveEaseOut | .LayoutSubviews, animations: { 
       cell.frame.size.height = size.height 
      }, completion: nil) 

collectionView!.performBatchUpdates(nil, completion: nil) 
相关问题