対象
- Facebook Pager 動画 http://vimeo.com/85421325
- 読んだソースはこちら
- -> https://github.com/hebertialmeida/HAPaperViewController/commit/8b0fefcc76d2c6acf134316f5587533db98a59ca
全体像
- navigationControllerにcollectionViewControllerを配置
- collectionViewControllerのcollectionViewを拡大縮小すると、navigationが遷移
- navigationControllerが遷移するとcustom animationが実行されて、拡大縮小のanimationを手でコントロールできる
- navigationControllerの遷移中にのanimation
- 背景の画像は定期的に切り替わるようになっている
- 横の動きはCollectionViewControllerの動き
詳細
-
HASmallCollectionViewControllerとHATransitionControllerの二つで構成されている。
-
HASmallCollectionViewController
- 背景画像のセット、背景画像の切り替え、collectionViewの横のスクロール
- 背景画像のセットと切り替え https://github.com/hebertialmeida/HAPaperViewController/blob/8b0fefcc76d2c6acf134316f5587533db98a59ca/Paper/HASmallCollectionViewController.m#L40-L162
-
HATransitionController
- navigationControllerのdelegateをappDelegateにセット。
-
navigationController:animationControllerForOperation:fromViewController:toViewController:
は、transition中にnoninteractiveなanimatorを返す -
navigationController:interactionControllerForAnimationController:
は、transition中に使われるインタラクティブなanimator objectを返す。 - animator objectとは、
NSObject<UIViewControllerAnimatedTransitioning, UIViewControllerInteractiveTransitioning>
のこと - animationControllerForOperation -> interactionControllerForAnimationController -> willShowViewController -> didShowViewControllerが呼ばれる
- interactionControllerForAnimationControllerの返り値のobjectで以下のmethodが呼ばれる。 https://github.com/hebertialmeida/HAPaperViewController/blob/8b0fefcc76d2c6acf134316f5587533db98a59ca/Paper/HATransitionController.m#L66-L87
一緒にコードリーディングしたメンバー
- http://qiita.com/morizotter
- http://qiita.com/south37
- wantedlyのもくもく会で、今回のコードリーディングしてみました
- 毎週木曜日にやってるので、ふらっと寄ってみてください
- -> https://www.wantedly.com/projects/5106
メモ
- main storyboardは使われてない
- HAViewControllerも使われていない
- UIPanGestureRecognizerも使われてない
- HATransitionControllerでpitchイベントとnavigationControllerのanimatorの両方のmethodが定義されていて少し混乱した
- 全体的にcollectionViewControllerとnavigationControllerのcustom animationを組み合わせると簡単に実装できそう