Ios 在导航堆栈上创建同时显示源视图和目标视图的转换?
本机推送转换显示源视图,无缝转换到目标视图 模式转换显示从底部覆盖源视图的目标视图 我想要一个与导航控制器一起工作的模式转换 到目前为止,我有:Ios 在导航堆栈上创建同时显示源视图和目标视图的转换?,ios,objective-c,core-animation,Ios,Objective C,Core Animation,本机推送转换显示源视图,无缝转换到目标视图 模式转换显示从底部覆盖源视图的目标视图 我想要一个与导航控制器一起工作的模式转换 到目前为止,我有: CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"]; anim.duration = .2; anim.autoreverses = NO; anim.removedOnCompletion = Y
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
anim.duration = .2;
anim.autoreverses = NO;
anim.removedOnCompletion = YES;
anim.fromValue = [NSNumber numberWithInt:sourceViewController.view.frame.size.height];
anim.toValue = [NSNumber numberWithInt:0];
[sourceViewController.navigationController.view.layer addAnimation:anim
forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
这在我的segue子类中的-perform
方法中。这样做的问题是导航控制器推送几乎是立即完成的,当转换发生时,源代码视图的任何内容都不会显示。我想让它看起来像是在覆盖
我认为可以使用核心图形拍摄屏幕截图,并将其作为目标视图的超级视图,但我无法使其正常工作
我还尝试使用UIView
动画方法之一,如下所示:
[sourceViewController.view addSubview:destinationController.view];
[destinationController.view setFrame:sourceViewController.view.window.frame];
[destinationController.view setTransform:CGAffineTransformMakeTranslation(0, sourceViewController.view.frame.size.height)];
[destinationController.view setAlpha:1.0];
[UIView animateWithDuration:1.3
delay:0.0
options:UIViewAnimationOptionTransitionNone
animations:^{
[destinationController.view setTransform:CGAffineTransformMakeTranslation(0, 0)];
[destinationController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationController.view removeFromSuperview];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
}];
但同样,这也存在一个问题:在视图控制器实际推到导航堆栈上之前,导航栏不会显示。因此,当导航栏突然显示时,动画末尾会出现一种“跳跃”
那么我的选择是什么呢?我通过创建源代码视图的图像并在此基础上进行转换来解决这个问题 另外,应该注意的是,ios 7上不存在“flash”,因此不需要太多自定义代码