[sourceViewController.view addSubview:destinationController.view];
[destinationController.view setFrame:sourceViewController.view.window.frame];
[destinationController.view setTransform:CGAffineTransformMakeScale(0.5,0.5)];
[destinationController.view setAlpha:0.0];
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationCurveEaseOut
animations:^{
[destinationController.view setTransform:CGAffineTransformMakeScale(1.0,1.0)];
[destinationController.view setAlpha:1.0];
//[sourceViewController.view setAlpha:0];
}
completion:^(BOOL finished){
[destinationController.view removeFromSuperview];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
}];
我的destinationController 有两个 View 。 View #1 是主视图,完全可见, View #2 是半可见半隐藏的。当我使用上面的代码并在 Segue 之间移动时,我可以看到(从 alpa 0 到 1 时)完全位于主视图下方的隐藏 View 。这样用户就可以看到隐藏在下面的内容。 (即使我使 animateWithDuration 变得非常快)。我不知道为什么会发生这种情况,并试图找到一个创造性的解决方案。我想出的一个解决方案是在 ViewController 内使用动画
[UIView animateWithDuration:0.7 animations:^() {_image.alpha = 1;}];
通过“减慢”隐藏 View ,但显然 View 是延迟加载的,并且在隐藏 View 的可见部分看起来不太优雅。
谢谢
最佳答案
您可以在动画之前先隐藏部分隐藏的 View ,或者设置另一个动画(将同时运行)以将隐藏 View 的 alpha 设置为 0。以与主视图相同或更快的速率运行此动画动画片。
关于ios - 主视图下的半隐藏 View 显示在 alpha segue 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14462698/