显示pushviewcontroller动画看起来像presentModalViewController

发布于 2024-09-25 20:24:17 字数 136 浏览 7 评论 0原文

是否可以显示 pushViewController 动画,看起来像 presentModalViewController 但具有 pushViewController 的后台功能?

Is it possible to show pushViewController animation look like presentModalViewController but that has background functionality of pushViewController?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

蒗幽 2024-10-02 20:24:17

如果您想要淡入淡出动画,此方法有效。

CATransition* transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromTop;

[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:gridController animated:NO];

If you want to a fade animation, this approach works.

CATransition* transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromTop;

[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:gridController animated:NO];
倦话 2024-10-02 20:24:17

试试这个:

UIViewController *yourViewController = [[UIViewController alloc]init];

[UIView  beginAnimations: @"Showinfo"context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController: yourViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

Try this :

UIViewController *yourViewController = [[UIViewController alloc]init];

[UIView  beginAnimations: @"Showinfo"context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController: yourViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
零度℉ 2024-10-02 20:24:17

对于显示 PushViewConttroler 动画,如下代码所示,

对于 Push

 ViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
 CATransition* transition = [CATransition animation];
 transition.duration = 0.4f;
 transition.type = kCATransitionMoveIn;
 transition.subtype = kCATransitionFromTop;
 [self.navigationController.view.layer addAnimation:transition
                                                    forKey:kCATransition];
 [self.navigationController pushViewController:VC animated:NO];

POP

CATransition* transition = [CATransition animation];
transition.duration = 0.4f;
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition
                                            forKey:kCATransition];
[self.navigationController popViewControllerAnimated:NO];

有 1 个问题,即它在向上/向下移动时显示浅黑色背景,< br>
正在努力,一旦完成就在这里发布新代码。

For display PushViewConttroler animation as Present below code is working,

For Push

 ViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
 CATransition* transition = [CATransition animation];
 transition.duration = 0.4f;
 transition.type = kCATransitionMoveIn;
 transition.subtype = kCATransitionFromTop;
 [self.navigationController.view.layer addAnimation:transition
                                                    forKey:kCATransition];
 [self.navigationController pushViewController:VC animated:NO];

And for POP

CATransition* transition = [CATransition animation];
transition.duration = 0.4f;
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition
                                            forKey:kCATransition];
[self.navigationController popViewControllerAnimated:NO];

There is 1 issue though, that its display light black background when its going up/down,
Working on that, As soon as its done post new code here.

眉目亦如画i 2024-10-02 20:24:17

对于所有尝试使用 Xamarin (C#) 等效代码的人
从上面 @hardik Thakkar 的回答来看,动画期间有黑色背景的问题,一切都好。

对于 POP

    CATransition transition = CATransition.CreateAnimation();
    transition.Duration = 0.4;
    transition.Type = CAAnimation.TransitionReveal;
    transition.Subtype = CAAnimation.TransitionFromTop;
    this.NavigationController.View.Layer.AddAnimation(transition, nameof(CATransition));

对于推送

    CATransition transition = CATransition.CreateAnimation();
    transition.Duration = 0.4;
    transition.Type = CAAnimation.TransitionReveal;
    transition.Subtype = CAAnimation.TransitionFromBottom;
    this.NavigationController.View.Layer.AddAnimation(transition, nameof(CATransition));

For All Trying in Xamarin (C#) equivalent Code
From Answer by @hardik Thakkar above, Has the issue of Black backgound during animation, rest all good.

For POP

    CATransition transition = CATransition.CreateAnimation();
    transition.Duration = 0.4;
    transition.Type = CAAnimation.TransitionReveal;
    transition.Subtype = CAAnimation.TransitionFromTop;
    this.NavigationController.View.Layer.AddAnimation(transition, nameof(CATransition));

For Push

    CATransition transition = CATransition.CreateAnimation();
    transition.Duration = 0.4;
    transition.Type = CAAnimation.TransitionReveal;
    transition.Subtype = CAAnimation.TransitionFromBottom;
    this.NavigationController.View.Layer.AddAnimation(transition, nameof(CATransition));
海风掠过北极光 2024-10-02 20:24:17

您应该考虑执行以下操作:

ViewController *myVC = [[ViewController alloc] initWithFrame:OFF_SCREEN];
[navigationController pushViewController:myVC animated:NO];

其中 OFF_SCREEN 是屏幕下方的某个 CGRect,例如 (0, 481, 320, 480)。然后使用动画块将viewcontroller的view的frame.origin调整为(0, 0)。您可能想要在 viewDidLoad 或 viewDidAppear 中执行动画块。

You should consider doing something like:

ViewController *myVC = [[ViewController alloc] initWithFrame:OFF_SCREEN];
[navigationController pushViewController:myVC animated:NO];

where OFF_SCREEN is some CGRect below the screen, like (0, 481, 320, 480). Then use an animation block to adjust the viewcontroller's view's frame.origin to be (0, 0). You would probably want to do the animate block in viewDidLoad or viewDidAppear.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文