2013-07-18 60 views
4

我使用uicollectionview呈現視圖控制器。我希望細胞從頂部進行動畫處理。UICollectionView最初動畫單元格

我的佈局是FlowLayout中的sublclass,所以我重寫此方法:暫時

- (UICollectionViewLayoutAttributes *) initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)indexPath { 
    UICollectionViewLayoutAttributes* attributes = [super initialLayoutAttributesForAppearingItemAtIndexPath:indexPath]; 
    CGFloat height = [self collectionViewContentSize].height; 
    attributes.transform3D = CATransform3DMakeTranslation(0, -height, 0); 
    return attributes; 
} 

它幾乎工作,但我看到的細胞出現(閃存)在屏幕上,他們在動畫之前

任何想法爲什麼他們在應用轉換之前出現在其最終位置,以及我如何防止這種情況?

回答

0

,而不是設置變換,改變中心:

- (UICollectionViewLayoutAttributes *) initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)indexPath { 
    UICollectionViewLayoutAttributes* attributes = [super initialLayoutAttributesForAppearingItemAtIndexPath:indexPath]; 
    CGPoint c = attributes.center; 
    c.y -= self.collectionViewContentSize.height; 
    attributes.center = c; 
    return attributes; 
} 

更改變換總能引起問題,確定的知名度,因爲這樣做無效的frame財產。

相關問題