【问题标题】:UIPercentDrivenInteractiveTransition does not interpolate transform propertyUIPercentDrivenInteractiveTransition 不插入变换属性
【发布时间】:2016-01-13 22:31:56
【问题描述】:

我目前正在尝试在两个视图控制器之间进行交互转换。这是一个被解雇的交互式动画。我使用UIPercentDrivenInteractiveTransition 的子类并执行在另一个对象动画器中实现的以下动画。

我没有成功进行插入toVC 视图的transform 属性的交互。

- (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 从上到下滑动。

滑动已正确插值,但变换只是完成但不插值。

哪里出错了

【问题讨论】:

    标签: ios7 controllers


    【解决方案1】:

    我也遇到了这个问题。对我来说,解决方案是转换toVC.view 的快照而不是toVC.view。我不确定为什么这是必要的。

    您可以使用snapshotViewAfterScreenUpdates: 拍摄快照。您还需要将toVC.view 的变换设置为CGAffineTransformIdentity 并在动画开始之前将其隐藏。然后,在完成块中取消隐藏它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 2019-11-19
      • 2012-02-19
      相关资源
      最近更新 更多