カスタム トランジション (iOS7、UIViewControllerAnimatedTransitioning) のアニメーションを実装しようとしています。UITableViewCell のサムネイル画像がフルスクリーンにズームアウトし始め、トランジションが新しい (モーダル) UIViewController フルスクリーンで終了し、背景画像が表示されます。ソースUITableViewCellのサムネイルの画像の高品質。
カスタム トランジションを使用するための「準備」コードは問題なく、デリゲートのメソッド内での実際のアニメーションの実装に苦労しています。
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
CGRect sourceRect = [transitionContext initialFrameForViewController:fromVC];
CGRect finalRect = [transitionContext finalFrameForViewController:toVC];
UIView *container = [transitionContext containerView];
if (self.mode == TRANSITION_MODE_INITIAL) {
//TODO: back to the table listing
} else if (self.mode == TRANSITION_MODE_MODAL) {
//TODO: take a thumbnail and zoom out, then replace with toVC's view?
}
}
選択した UITableViewCell をこのカスタム Transition クラスに渡しているため、セルのすべてのサブビューにアクセスしてアニメーションを実装できます。
うまく取れない点:
- 実際のサムネイルをスケーリングするのではなく、toVC をズームインしてサムネイルの位置 (フレーム) に配置し、ズームアウトをアニメーション化するだけでよいでしょうか?
- ここでのコンテナの役割は何ですか? 正しい使い方は?