Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIViewAnimationOption枚举覆盖垂直_Ios_Objective C - Fatal编程技术网

Ios UIViewAnimationOption枚举覆盖垂直

Ios UIViewAnimationOption枚举覆盖垂直,ios,objective-c,Ios,Objective C,我想推送一个带有自定义模态动画的ViewController。我更喜欢使用“封面垂直”动画。“封面垂直”是否有ui视图动画选项 将中的UIViewAnimationOptionCurveEaseIn替换为?或者有更好的方法吗?您需要使用动画控制器。设置此设置的代码如下所示: - (id)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewContro

我想推送一个带有自定义模态动画的ViewController。我更喜欢使用“封面垂直”动画。“封面垂直”是否有
ui视图动画选项


将中的UIViewAnimationOptionCurveEaseIn替换为?或者有更好的方法吗?

您需要使用动画控制器。设置此设置的代码如下所示:

- (id)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController (UIViewController *)source
{
    return self.animationController;
}

- (id )animationControllerForDismissedController:(UIViewController *)dismissed {
     self.animationController.isPresenting = NO;

    return self.animationController;
}
然后,您需要使用以下方法确定您是在陈述还是拒绝:

-(void)animateTransition:(id)transitionContext{

if(self.isPresenting){
    [self executePresentationAnimation:transitionContext];
}
else{
    [self executeDismissalAnimation:transitionContext];
}

}
最后,定义动画后,以下代码将从顶部将视图作为模式视图推入:

-(void)executePresentationAnimation:(id)transitionContext{

UIView* inView = [transitionContext containerView];

UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

[inView addSubview:toViewController.view];

CGPoint centerOffScreen = inView.center;

centerOffScreen.y = (-1)*inView.frame.size.height;
toViewController.view.center = centerOffScreen;

[UIView animateWithDuration:self.presentationDuration delay:0.0f usingSpringWithDamping:0.4f initialSpringVelocity:6.0f options:UIViewAnimationOptionCurveEaseIn animations:^{

    toViewController.view.center = inView.center;

} completion:^(BOOL finished) {

    [transitionContext completeTransition:YES];
}];
}
当你放弃时,相反的情况会发生:

-(void)executeDismissalAnimation:(id)transitionContext{

UIView* inView = [transitionContext containerView];

UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

UIViewController* fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];

[inView insertSubview:toViewController.view belowSubview:fromViewController.view];

CGPoint centerOffScreen = inView.center;
centerOffScreen.y = (-1)*inView.frame.size.height;

[UIView animateKeyframesWithDuration:self.dismissalDuration delay:0.0f options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{

    [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.5 animations:^{

        CGPoint center = fromViewController.view.center;
        center.y += 50;
        fromViewController.view.center = center;
    }];

    [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{

        fromViewController.view.center = centerOffScreen;

    }];


} completion:^(BOOL finished) {
    [transitionContext completeTransition:YES];
}];
}
-(void)executeDismissalAnimation:(id)transitionContext{

UIView* inView = [transitionContext containerView];

UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

UIViewController* fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];

[inView insertSubview:toViewController.view belowSubview:fromViewController.view];

CGPoint centerOffScreen = inView.center;
centerOffScreen.y = (-1)*inView.frame.size.height;

[UIView animateKeyframesWithDuration:self.dismissalDuration delay:0.0f options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{

    [UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.5 animations:^{

        CGPoint center = fromViewController.view.center;
        center.y += 50;
        fromViewController.view.center = center;
    }];

    [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{

        fromViewController.view.center = centerOffScreen;

    }];


} completion:^(BOOL finished) {
    [transitionContext completeTransition:YES];
}];
}