简体   繁体   English

如何使用自定义UIViewController过渡来实现此目的?

[英]How can I use custom UIViewController transitions to achieve this?

So I have a flow in my app where all the view controllers have the same gradient background (using a UIImageView). 因此,我的应用程序中存在一个流程,其中所有视图控制器具有相同的渐变背景(使用UIImageView)。

I'm presenting each of them modally with a cross-dissolve transition as opposed to using a navigation controller because I don't want the horizontal push/pop transition. 与使用导航控制器相反,我为每个模型都提供了交叉溶解过渡,因为我不希望水平推送/弹出过渡。 Is there a better way to do this? 有一个更好的方法吗? Perhaps using a navigation controller and disabling the push/pop animation and just fading/pushing the UI elements into the view? 也许使用导航控制器并禁用推/弹出动画,而只是将UI元素淡入/推入视图中?

I want it to look like the background never changes through the workflow, but the ui elements/contents for each view controller do change. 我希望它看起来像背景在整个工作流程中都不会改变,但是每个视图控制器的ui元素/内容都会改变。

You could provide a custom push / pop animation, if the animation is fairly easy to do.: 如果该动画非常容易实现,则可以提供自定义的推送/弹出动画。

[UIView animateWithDuration:0.75
                         animations:^{
                             [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                             [self.navigationController pushViewController:nextView animated:NO];
                             [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
                         }];

[UIView animateWithDuration:0.75
                         animations:^{
                             [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                             [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
                         }];
[self.navigationController popViewControllerAnimated:NO];

Source . 来源


If the animation isn't so easy, it's perfectly fine to present your view controllers modally if you don't need the navigation bar, but you'll have to provide your own popToViewController:animated: equivalent (since I don't know any way to dismiss more than one view controller). 如果动画不太容易,那么如果不需要导航栏,最好以模态方式显示视图控制器,但是您必须提供自己的popToViewController:animated:等效项(因为我不知道解除多个视图控制器的方式)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何实现从UICollectionViewController到UIViewController的自定义UIViewController转换? - How can I achieve this custom UIViewController Transition from UICollectionViewController to UIViewController? 自定义UIViewController在Swift中使用animateWithDuration进行转换 - Custom UIViewController transitions with animateWithDuration in Swift 自定义 UIViewController 转换上的 UIView 快照 - UIView snapshots on custom UIViewController transitions 如何在SwiftUI中使用UIViewController和UIView? - How can I use UIViewController and UIView in SwiftUI? 如何在 UIViewController 中使用 applicationDidBecomeActive? - How can I use applicationDidBecomeActive in UIViewController? 如何在UIViewController属性中使用willSet - How can I use willSet in a UIViewController property 如何使用SnapKit实现此目的? - How can I use SnapKit achieve this? 如何在Swift 4中从自定义类导航到UIViewController - How can I navigate from custom class to UIViewController in Swift 4 如何将Storyboard UIViewController与我的自定义UIViewController类相关联? - How do I associate a Storyboard UIViewController with my custom UIViewController class? 我可以使用一个自定义创建的UIViewController填充父UITableViewController的单元格文本值吗? - Can I use one custom created UIViewController to populating cells text value of parent UITableViewController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM