LoginSignup
11
11

More than 5 years have passed since last update.

UICollectionViewLayoutの切替アニメーションの速度を調整する

Last updated at Posted at 2014-05-10

UICollectionViewは複数のレイアウトをアニメーション付きで簡単に切り替えることができる。ただ、切り替える時のアニメーションの速度を調整する方法がなくて困っていた。これはUICollectionViewFlowLayoutだけではなく、カスタムレイアウトの時も同じ。

いろいろ調べてみたら、単純にUIViewのanimationDuration:animationsメソッド内でアニメーションを切り替えてやればよいことがわかった。

[UIView animateWithDuration:1.f animations:^{
  [self.collectionView setCollectionViewLayout:self.flowLayout animated:YES];
}];



こんな感じで書くと現在のレイアウトからの切り替わる速度を調整できる。

11
11
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
11
11