我目前正在尝试在两个视图控制器之间进行交互式转换。这是一个被解雇的互动动画。我使用UIPercentDrivenInteractiveTransition
的子类,并在另一个对象动画师中执行以下动画。
我没有成功进行内插transform
视图的toVC
属性的交互。
- (void) animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
NSLog(@"Animate!!");
//Basic container
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
fromVC.view.frame = [transitionContext initialFrameForViewController:fromVC];
toVC.view.frame = [transitionContext finalFrameForViewController:fromVC];
toVC.view.transform = CGAffineTransformMakeScale(0.9, 0.9);
//[transitionContext.containerView insertSubview:toVC.view belowSubview:fromVC.view];
NSTimeInterval duration = [self transitionDuration:transitionContext];
[UIView animateWithDuration:duration animations:^{
[fromVC beginAppearanceTransition:NO animated:YES];
fromVC.view.frame = CGRectMake(0, CGRectGetHeight(fromVC.view.frame), CGRectGetWidth(fromVC.view.frame), CGRectGetHeight(fromVC.view.frame));
toVC.view.transform = CGAffineTransformIdentity;
[toVC beginAppearanceTransition:YES animated:YES];
} completion:^(BOOL finished){
[transitionContext completeTransition:![transitionContext transitionWasCancelled]];
if(finished)
{
[fromVC endAppearanceTransition];
[toVC endAppearanceTransition];
}
}];
}
我想让toVC以刻度开始并完成以适应屏幕,同时fromVC从上到下滑动。
滑动是正确插值的,但转换只是完成但不进行插值。
错误在哪里
答案 0 :(得分:0)
我也遇到了这个问题。对我来说,解决方案是转换toVC.view
而不是toVC.view
的快照。我不确定为什么这是必要的。
您可以使用snapshotViewAfterScreenUpdates:
拍摄快照。您还需要将toVC.view
的变换设置为CGAffineTransformIdentity
并在动画开始之前隐藏它。然后,在完成块中取消隐藏它。