2015-04-30 57 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) 
相關問題