LoginSignup
1
2

More than 5 years have passed since last update.

右からスライドインしてくるCollectionViewのアニメーション

Last updated at Posted at 2018-05-15

CollectionView表示時に右からスライドインするアニメーションをつけた際の備忘録

スクリーンショット 2018-05-15 17.51.16.png

↑こんなのをつくりたい

実装

- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {

    CGRect cellRect = cell.frame;
    cell.frame = CGRectMake(self.mCollectionCell * indexPath.row + self.view.frame.size.width, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height);
    float value = indexPath.row * 0.1;
    [UIView animateWithDuration:1 delay:value options:UIViewAnimationOptionCurveEaseInOut animations:^{
        cell.frame = CGRectMake(cellRect.origin.x + self.view.frame.size.width, cellRect.origin.y, cellRect.size.width, cellRect.size.height);
    } completion:^(BOOL finished) {
        cell.frame = cellRect;
        }];
    }];

これで右からスライドしてくるcollectionViewを実装できた。
もっといい方法あったら知りたい。。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2