我正忙于UIViewControllers之间的自定义动画过渡,我喜欢UIView跳转,然后填充类似于以下屏幕截图的空间:
现在没有“选项”我可以创造这样的效果。现在我可以创建一个关键帧动画,顶部有一个键,中间有一个键但是感觉不自然,它会感觉机器人。
如何处理这个?
消息来源(SO FAR)
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *container = [transitionContext containerView];
if ([fromVC isEqual:self])
{
[_activeCardView.superview bringSubviewToFront:_activeCardView];
[UIView animateKeyframesWithDuration:[self transitionDuration:transitionContext]
delay:0.0
options:UIViewKeyframeAnimationOptionCalculationModeCubic
animations:^{
[_activeCardView setFrame:CGRectMake(0.0, 0.0, toVC.view.bounds.size.width, toVC.view.bounds.size.height)];
}
completion:^(BOOL finished){
[container addSubview:toVC.view];
[transitionContext completeTransition:YES];
}];
}
else
{
[container addSubview:toVC.view];
[UIView animateWithDuration:[self transitionDuration:transitionContext]
animations:^{
[_activeCardView setFrame:_basicCardFrame];
}
completion:^(BOOL finished){
[transitionContext completeTransition:YES];
}];
}
}
答案 0 :(得分:0)
顺利跳跃&#39;动画,您可以使用&#39; EaseInOut&#39;链接两个动画。曲线。
[UIView animateWithDuration:<DURATION>/2 delay:<DELAY> options:UIViewAnimationOptionCurveEaseInOut animations:^(void) {
//move view up
}completion:^(BOOL finished) {
[UIView animateWithDuration:<DURATION>/2 delay:<DELAY> options:UIViewAnimationOptionCurveEaseInOut animations:^(void) {
//move view down
}completion:NULL];
}];