UICollectionView加载动效

动效.gif
//[collectionView reloadData]后执行
- (void)shrinkToTopAnimationWithTableView:(UICollectionView *)collectionView {
    [collectionView layoutSubviews];
    //UICollectionView需先执行layoutSubviews 才可获取visibleCells
    NSArray *cells = [collectionView visibleCells];
    for (int i = 0; i < cells.count; i++) {
        UICollectionViewCell *cell = [cells objectAtIndex:i];
        cell.transform = CGAffineTransformMakeTranslation(0, 30);
        cell.alpha = 0.5;
        [UIView animateWithDuration:0.4 animations:^{
            cell.transform = CGAffineTransformIdentity;
            cell.alpha = 1;
        }];
    }
}

你可能感兴趣的:(UICollectionView加载动效)